export type CreateApiDisputeDisputesAlertsAlertIdActionArgs = {alertId: string, 'x-idempotency-key': string, body: {result: 'Resolved' | 'AlreadyRefunded' | 'AlreadyChargeback' | 'Ineligible' | 'MIDLost' | 'NotMyDescriptor' | 'EscalateChargeback' | 'TDS' | 'UnmatchedCannotFindTransaction', notes?: string | undefined}}; export type CreateApiDisputeDisputesAlertsAlertIdActionOptions = {baseUrl?: string | undefined, BearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Action a Dispute Alert * * POST /dispute/disputes/alerts/{alertId}/action */ export const createApiDisputeDisputesAlertsAlertIdAction = async (args: CreateApiDisputeDisputesAlertsAlertIdActionArgs, options?: CreateApiDisputeDisputesAlertsAlertIdActionOptions) => { const {baseUrl = "https://api.staging.payrails.io", fetch: fetchFn = fetch, BearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-idempotency-key'] != null) headers.set("x-idempotency-key", String(args['x-idempotency-key'])) if (BearerToken !== undefined) headers.set('authorization', `Bearer ${BearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/dispute/disputes/alerts/${encodeURIComponent(String(args.alertId))}/action${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 };