export type CreateApiWithdrawalPixNewArgs = {body: {amount: number, document_id: string, beneficiaryName: string, beneficiaryLastName: string, beneficiaryEmail: string, beneficiaryPhone: string, accountType: string, bankCode: string, data: string, confirmationURL: string, currency: string, country: string, sign: string, pagamentoType: number, type: string, accountNumber: string, agency?: string | undefined, ispb?: string | undefined}}; export type CreateApiWithdrawalPixNewOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Crear un nuevo retiro - Brasil Pix * * POST /withdrawal/pix/new */ export const createApiWithdrawalPixNew = async (args: CreateApiWithdrawalPixNewArgs, options?: CreateApiWithdrawalPixNewOptions) => { const {baseUrl = "https://sandbox.prontopaga.com/api", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/withdrawal/pix/new${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };