export type GetApiV3InvoiceExportArgs = {merchantId?: string | undefined, filter?: string | undefined, startDate?: string | undefined, endDate?: string | undefined, dateType?: ('Day' | 'Yesterday' | 'Week' | 'Month' | 'Last7' | 'Last30' | 'Year' | 'Lifetime' | 'Custom' | 'Values: Day' | 'Today' | 'NextMonth' | 'Next7' | 'Next30' | 'Custom.') | undefined, minAmount?: string | undefined, maxAmount?: string | undefined, status?: string | undefined, term?: string | undefined}; export type GetApiV3InvoiceExportOptions = {baseUrl?: string | undefined, sec0?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Invoice Export * * GET /v3/invoice/export */ export const getApiV3InvoiceExport = async (args: GetApiV3InvoiceExportArgs, options?: GetApiV3InvoiceExportOptions) => { const {baseUrl = "https://sandbox.api.mxmerchant.com/checkout", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.merchantId != null) query.append("merchantId", String(args.merchantId)) if (args.filter != null) query.append("filter", String(args.filter)) if (args.startDate != null) query.append("startDate", String(args.startDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (args.dateType != null) query.append("dateType", String(args.dateType)) if (args.minAmount != null) query.append("minAmount", String(args.minAmount)) if (args.maxAmount != null) query.append("maxAmount", String(args.maxAmount)) if (args.status != null) query.append("status", String(args.status)) if (args.term != null) query.append("term", String(args.term)) if (sec0 !== undefined) headers.set('authorization', `Basic ${btoa(`${sec0.username}:${sec0.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/invoice/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) 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 };