This commit is contained in:
andreLMpena 2024-12-02 11:01:56 -03:00
parent 1d2ac18171
commit 0172055539
15 changed files with 44 additions and 41 deletions

View file

@ -1,43 +0,0 @@
import node_fetch from "cross-fetch"
import { respostaComuns, type tipoResposta } from "p-respostas"
import type { z } from "zod"
import type { zAmbiente } from "../ts/ambiente"
import { urlAutenticacao } from "./_urlAutenticacao"
import { tipos_de_acesso_quipo } from "../tokenQuipo"
export type tipoUsuarioExterno = {
nome: string
email: string
telefone: string
vinculo: string
codigo_conta: string
chave_produto: string
codigo: string
}
export const usuarios_quipo = async ({
token_produto,
ambiente,
tipo,
}: {
ambiente: z.infer<typeof zAmbiente>
token_produto: string
tipo: tipos_de_acesso_quipo,
}): Promise<tipoResposta<tipoUsuarioExterno[]>> => {
const url = `${urlAutenticacao(ambiente)}/api/usuarios_quipo/${tipo}`
if (!token_produto) return respostaComuns.erro("token_produto não informado")
const headers = {
token: token_produto,
}
return node_fetch(url, {
headers,
})
.then((r) => r.json())
.catch((e) =>
respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`),
)
.then((r) => r as tipoResposta<tipoUsuarioExterno[]>)
}