export type CreateApiApiV4EcommerceIntegrationPartnerKeyApplicationArgs = {'partner-key': string, 'x-auth-token': string, body: {orderId: string, requestedAmount: number, productDescription: string, customerName: string, customerEmail: string, customerPhone: string, successUrl?: string | undefined, failureUrl?: string | undefined}}; export type CreateApiApiV4EcommerceIntegrationPartnerKeyApplicationOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generar orden * * POST /api/v4/ecommerce/integration/{partner-key}/application */ export const createApiApiV4EcommerceIntegrationPartnerKeyApplication = async (args: CreateApiApiV4EcommerceIntegrationPartnerKeyApplicationArgs, options?: CreateApiApiV4EcommerceIntegrationPartnerKeyApplicationOptions) => { const {baseUrl = "https://api-sandbox.atratopago.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-auth-token'] != null) headers.set("x-auth-token", String(args['x-auth-token'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v4/ecommerce/integration/${encodeURIComponent(String(args['partner-key']))}/application${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 };