export type Partner = number; export type BusinessUnitId = number; export type TaxNumber = string; export type PaymentDate = number; export type PaymentOrderStatus = 'Created = 0' | 'CanBeAuthorized = 1' | 'Settled = 2' | 'Canceled = 3' | 'Registered = 4' | 'CanBeSettled = 5' | 'Error = 6' | 'Verifying = 7' | 'CanBeRegenerated = 8' | 'CanBeRegister = 9' | 'CanBeSettleDeniedBeneficiary = 10' | 'SettledDeniedBeneficiary = 11' | 'PreRegistered = 12' | 'CanBePreAuthorized = 13' | 'CanBePreSettleDeniedBeneficiary = 14' | 'ErrorBalance = 15' | 'PreCanceled = 16' | 'Pending = 17' | 'PreCreated = 18' | 'VerifyingBeneficiary = 19'; export type PaymentOrderId = number; export type Identifier = string; export type PageSize = number; export type Index = number; export type GetPaymentOrder = {Method: string, PartnerId: Partner, BusinessUnitId: BusinessUnitId, TaxNumber?: TaxNumber | undefined, PaymentDate?: PaymentDate | undefined, PaymentOrderStatus?: PaymentOrderStatus | undefined, PaymentOrderId?: PaymentOrderId | undefined, Identifier?: Identifier | undefined, PageSize?: PageSize | undefined, Index?: Index | undefined}; export type CreateApiGetPaymentOrderArgs = {body: GetPaymentOrder}; export type CreateApiGetPaymentOrderOptions = {baseUrl?: string | undefined, BASE64UsernamePassword?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get Payment Order * * POST /GetPaymentOrder */ export const createApiGetPaymentOrder = async (args: CreateApiGetPaymentOrderArgs, options?: CreateApiGetPaymentOrderOptions) => { const {baseUrl = "https://sandboxapi.fitbank.com.br/main/execute", fetch: fetchFn = fetch, BASE64UsernamePassword} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "Success") if (BASE64UsernamePassword !== undefined) headers.set('authorization', `Basic ${btoa(`${BASE64UsernamePassword.username}:${BASE64UsernamePassword.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/GetPaymentOrder${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 res.blob() };