.
This commit is contained in:
parent
2fb80e6683
commit
645b3b551e
6 changed files with 28 additions and 32 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { tipoResposta } from "~comuns"
|
||||
import { respostaComuns, type tipoResposta } from "~comuns"
|
||||
type tipoPostValidarTokem = { token: string }
|
||||
type tipoPostCodigoContaSite = { site: string }
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ const validarToken = async ({
|
|||
}
|
||||
}
|
||||
|
||||
const codigoPrefeituraSite = async ({
|
||||
const codigoContaSite = async ({
|
||||
ambiente,
|
||||
post,
|
||||
buscar,
|
||||
|
|
@ -50,21 +50,19 @@ const codigoPrefeituraSite = async ({
|
|||
url: string,
|
||||
post: tipoPostCodigoContaSite,
|
||||
) => Promise<tipoResposta<string>>
|
||||
}): Promise<"valido" | "erro"> => {
|
||||
}): Promise<tipoResposta<string>> => {
|
||||
const url = `${urlAutenticacao(
|
||||
ambiente,
|
||||
)}/autenticacao/api/codigo_prefeitura_site`
|
||||
|
||||
try {
|
||||
const resposta = await buscar(url, post)
|
||||
.then((resposta) =>
|
||||
resposta.eCerto ? ("valido" as const) : ("erro" as const),
|
||||
)
|
||||
.catch((e) => "erro" as const)
|
||||
const resp = await buscar(url, post).catch((e) =>
|
||||
respostaComuns.erro(`erro ao buscar código do site: ${e}`),
|
||||
)
|
||||
|
||||
return resposta
|
||||
return resp
|
||||
} catch (e) {
|
||||
return "erro"
|
||||
return respostaComuns.erro(`erro ao buscar código do site: ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,5 +70,5 @@ const codigoPrefeituraSite = async ({
|
|||
export const pAutenticacao = {
|
||||
validarToken,
|
||||
urlAutenticacao,
|
||||
codigoPrefeituraSite,
|
||||
codigoContaSite,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue