export type GetApiV3ReportChargebackArgs = {merchantId: number, dateTypeFilter?: string | undefined, startDate: string, endDate: string, limit?: number | undefined, offset?: number | undefined}; export type GetApiV3ReportChargebackOptions = {baseUrl?: string | undefined, sec0?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get Chargebacks Report * * GET /v3/report/chargeback */ export const getApiV3ReportChargeback = async (args: GetApiV3ReportChargebackArgs, options?: GetApiV3ReportChargebackOptions) => { 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.dateTypeFilter != null) query.append("dateTypeFilter", String(args.dateTypeFilter)) if (args.startDate != null) query.append("startDate", String(args.startDate)) if (args.endDate != null) query.append("endDate", String(args.endDate)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (sec0 !== undefined) headers.set('authorization', `Basic ${btoa(`${sec0.username}:${sec0.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/report/chargeback${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 };