export type PatchApiV0MandatesMandateIdArgs = {'mandate-id': string, body: {status?: ('cancelled' | 'active' | 'expired') | undefined, 'cancellation-reason'?: ('cancelled-by-griffin' | 'debtor-deceased' | 'cancelled-by-creditor' | 'account-closed' | 'cancelled-by-debtor') | undefined}}; export type PatchApiV0MandatesMandateIdOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update mandate * * PATCH /v0/mandates/{mandate-id} */ export const patchApiV0MandatesMandateId = async (args: PatchApiV0MandatesMandateIdArgs, options?: PatchApiV0MandatesMandateIdOptions) => { const {baseUrl = "https://api.griffin.com", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyAuth !== undefined) headers.set("Authorization", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v0/mandates/${encodeURIComponent(String(args['mandate-id']))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };