export type ApplyCreditMemoRequestDto = {invoiceId: string, amount?: number | undefined}; export type CreateApiV3CreditMemosIdApplicationsArgs = {id: string, body: ApplyCreditMemoRequestDto}; export type CreateApiV3CreditMemosIdApplicationsOptions = {baseUrl?: string | undefined, customHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Apply credit memo * * POST /v3/credit-memos/{id}/applications */ export const createApiV3CreditMemosIdApplications = async (args: CreateApiV3CreditMemosIdApplicationsArgs, options?: CreateApiV3CreditMemosIdApplicationsOptions) => { const {baseUrl = "https://integrators.prod.api.tabsplatform.com", fetch: fetchFn = fetch, customHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (customHeader !== undefined) headers.set("Authorization", customHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v3/credit-memos/${encodeURIComponent(String(args.id))}/applications${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 };