export type CreateApiBrasilPixArgs = {body: {accountType?: string | undefined, theme?: string | undefined, bankCode?: string | undefined, addressLine1?: string | undefined, codePostal?: string | undefined, city?: string | undefined, branchCode?: string | undefined, accountNumber?: string | undefined}}; export type CreateApiBrasilPixOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /brasil-Pix */ export const createApiBrasilPix = async (args: CreateApiBrasilPixArgs, options?: CreateApiBrasilPixOptions) => { 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(/\/+$/, '')}/brasil-Pix${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 };