export type CreateApiCasesCaseIdFilesArgs = {caseId: string, sendChatNotification?: boolean | undefined, 'Idempotency-Key'?: string | undefined, body: BodyInit}; export type CreateApiCasesCaseIdFilesOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a file to a case. Optionally posts a system chat message to notify the collection partner. * * POST /cases/{caseId}/files */ export const createApiCasesCaseIdFiles = async (args: CreateApiCasesCaseIdFilesArgs, options?: CreateApiCasesCaseIdFilesOptions) => { const {baseUrl = "https://referral-api.debitura.com", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.sendChatNotification != null) query.append("sendChatNotification", String(args.sendChatNotification)) if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (ApiKey !== undefined) headers.set("XApiKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/cases/${encodeURIComponent(String(args.caseId))}/files${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };