Cleaned code and prepared for API communications.

This commit is contained in:
Filipe Soccol
2024-12-01 11:50:08 -03:00
parent 92f6cb4d35
commit c4dae86b5f
6 changed files with 64 additions and 100 deletions

43
src/utils/bbPay.ts Normal file
View File

@@ -0,0 +1,43 @@
export interface Participant {
offer: string;
fullName: string;
identification: string;
bankIspb?: string;
accountType: string;
account: string;
branch: string;
savingsVariation?: string;
}
export interface ParticipantWithID extends Participant {
id: string;
}
export interface Offer {
amount: number;
sellerID: string;
}
export const createParticipant = async (participant: Participant) => {
const response = await fetch(`${process.env.VUE_APP_API_URL}/participants`, {
method: "PUT",
body: JSON.stringify(participant),
});
const data = await response.json();
return { ...participant, id: data.id } as ParticipantWithID;
};
export const createSolicitation = async (offer: Offer) => {
const response = await fetch(`${process.env.VUE_APP_API_URL}/solicitation`, {
method: "POST",
body: JSON.stringify(offer),
});
return response.json();
};
export const getSolicitation = async (id: string) => {
const response = await fetch(
`${process.env.VUE_APP_API_URL}/solicitation/${id}`
);
return response.json();
};