43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import node_fetch from "cross-fetch"
|
|
import { respostaComuns, type tipoResposta } from "p-respostas"
|
|
import type { tipo_usuarios__listar_retorno } from "../lista-usuarios"
|
|
import { site_autenticacao } from "../utilitarios/site_autenticacao"
|
|
|
|
export type tipoUsuarioExterno = {
|
|
_nome: string
|
|
_email: string
|
|
_telefone: string
|
|
vinculo: string
|
|
inquilino: string
|
|
chave_produto: string
|
|
codigo: string
|
|
_cpf: string
|
|
}
|
|
|
|
export const usuarios_quipo = async ({
|
|
token_produto,
|
|
base_url_autenticacao,
|
|
inquilino,
|
|
}: {
|
|
base_url_autenticacao: string
|
|
token_produto: string
|
|
inquilino: string
|
|
}): Promise<tipoResposta<tipo_usuarios__listar_retorno[]>> => {
|
|
const url = `${site_autenticacao(base_url_autenticacao)}/api/usuarios__listar`
|
|
|
|
if (!token_produto) return respostaComuns.erro("token_produto não informado")
|
|
|
|
const headers = {
|
|
token: token_produto,
|
|
"Content-Type": "application/json",
|
|
}
|
|
|
|
return node_fetch(url, {
|
|
method: "POST",
|
|
body: JSON.stringify({ inquilino }),
|
|
headers,
|
|
})
|
|
.then((r) => r.json())
|
|
.catch((e) => respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`))
|
|
.then((r) => r as tipoResposta<tipo_usuarios__listar_retorno[]>)
|
|
}
|