funcao para criar vinculo de usuario
This commit is contained in:
parent
78acaa0816
commit
b5360ab1a9
9 changed files with 360 additions and 216 deletions
|
|
@ -33,7 +33,7 @@ export const usuarios_quipo_governo = async ({
|
|||
})
|
||||
.then((r) => r.json())
|
||||
.catch((e) =>
|
||||
respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]),
|
||||
respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`),
|
||||
)
|
||||
.then((r) => r as tipoResposta<tipoUsuarioExterno[]>)
|
||||
}
|
||||
|
|
|
|||
43
src/autenticacao/_usuarios_quipo_vincular.ts
Normal file
43
src/autenticacao/_usuarios_quipo_vincular.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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"
|
||||
|
||||
export const usuarios_quipo_vincular = async ({
|
||||
token_produto,
|
||||
ambiente,
|
||||
conta,
|
||||
vinculo,
|
||||
codigo_usuario,
|
||||
}: {
|
||||
ambiente: z.infer<typeof zAmbiente>
|
||||
token_produto: string
|
||||
conta: string
|
||||
vinculo: string
|
||||
codigo_usuario: string
|
||||
}): Promise<tipoResposta<string>> => {
|
||||
const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`
|
||||
|
||||
if (!token_produto) return respostaComuns.erro("token_produto não informado")
|
||||
|
||||
const headers = {
|
||||
token: token_produto,
|
||||
}
|
||||
|
||||
const parametros = {
|
||||
codigo_conta: conta,
|
||||
codigo_usuario,
|
||||
vinculo,
|
||||
}
|
||||
|
||||
return node_fetch(url, {
|
||||
headers,
|
||||
body: JSON.stringify(parametros),
|
||||
})
|
||||
.then((r) => String(r))
|
||||
.catch((e) =>
|
||||
respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`),
|
||||
)
|
||||
.then((r) => r as tipoResposta<string>)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue