Fixes bbPay interface with proper calls.

This commit is contained in:
Filipe Soccol 2025-05-21 11:30:22 -03:00
parent 8eb10f493f
commit 75c02ed1b9

View File

@ -1,3 +1,5 @@
import { off } from "process";
export interface Participant { export interface Participant {
offer: string; offer: string;
chainID: number; chainID: number;
@ -24,37 +26,42 @@ export interface Offer {
export const createParticipant = async (participant: Participant) => { export const createParticipant = async (participant: Participant) => {
console.log("Creating participant", participant); console.log("Creating participant", participant);
const response = await fetch( const response = await fetch(`${import.meta.env.VITE_APP_API_URL}/register`, {
`${import.meta.env.VITE_APP_API_URL}/participants`, method: "POST",
{
method: "PUT",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(participant), body: JSON.stringify({
} chainID: participant.chainID,
); tipoDocumento: 1,
numeroDocumento: participant.identification,
numeroConta: participant.account,
numeroAgencia: participant.branch,
tipoConta: participant.accountType,
codigoIspb: participant.bankIspb,
}),
});
const data = await response.json(); const data = await response.json();
return { ...participant, id: data.id } as ParticipantWithID; return { ...participant, id: data.id } as ParticipantWithID;
}; };
export const createSolicitation = async (offer: Offer) => { export const createSolicitation = async (offer: Offer) => {
const response = await fetch( const response = await fetch(`${import.meta.env.VITE_APP_API_URL}/request`, {
`${import.meta.env.VITE_APP_API_URL}/solicitation`,
{
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify(offer), body: JSON.stringify({
} amount: offer.amount,
); pixTarget: offer.sellerId,
}),
});
return response.json(); return response.json();
}; };
export const getSolicitation = async (id: string) => { export const getSolicitation = async (id: string) => {
const response = await fetch( const response = await fetch(
`${import.meta.env.VITE_APP_API_URL}/solicitation/${id}` `${import.meta.env.VITE_APP_API_URL}/release/${id}`
); );
const obj: any = response.json(); const obj: any = response.json();