export type CreateReceiptDeliveryAttempt = {requested_delivery_methods: Array<{destinations: Array, type: 'EMAIL' | 'PRINT' | 'SMS'}>}; export type CreateApiReceiptsReceiptIdDeliveryAttemptsArgs = {'Finix-Version'?: string | undefined, 'Content-Type'?: string | undefined, body: CreateReceiptDeliveryAttempt}; export type CreateApiReceiptsReceiptIdDeliveryAttemptsOptions = {baseUrl?: string | undefined, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Create a Delivery Attempt * * POST /receipts/{receipt_id}/delivery_attempts */ export const createApiReceiptsReceiptIdDeliveryAttempts = async (args: CreateApiReceiptsReceiptIdDeliveryAttemptsArgs, options?: CreateApiReceiptsReceiptIdDeliveryAttemptsOptions) => { const {baseUrl = "https://finix.sandbox-payments-api.com", fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Finix-Version'] != null) headers.set("Finix-Version", String(args['Finix-Version'])) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/receipts/${encodeURIComponent(String(args.receipt_id))}/delivery_attempts${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 undefined };