export type CreateApiApiV1ClientsIdPurgeArgs = {'X-API-TOKEN': string, 'X-Requested-With': string, 'X-API-PASSWORD': string, id: unknown}; export type CreateApiApiV1ClientsIdPurgeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Purge client * * POST /api/v1/clients/{id}/purge */ export const createApiApiV1ClientsIdPurge = async (args: CreateApiApiV1ClientsIdPurgeArgs, options?: CreateApiApiV1ClientsIdPurgeOptions) => { const {baseUrl = "https://demo.invoiceninja.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-API-TOKEN'] != null) headers.set("X-API-TOKEN", String(args['X-API-TOKEN'])) if (args['X-Requested-With'] != null) headers.set("X-Requested-With", String(args['X-Requested-With'])) if (args['X-API-PASSWORD'] != null) headers.set("X-API-PASSWORD", String(args['X-API-PASSWORD'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/clients/${encodeURIComponent(String(args.id))}/purge${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };