export type DeleteApiV1AccountsIdArgs = {id: number, disconnect_reason?: string | undefined, 'x-api-key': string}; export type DeleteApiV1AccountsIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete an account * * DELETE /v1/accounts/{id} */ export const deleteApiV1AccountsId = async (args: DeleteApiV1AccountsIdArgs, options?: DeleteApiV1AccountsIdOptions) => { const {baseUrl = "https://api.mailreach.co/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.disconnect_reason != null) query.append("disconnect_reason", String(args.disconnect_reason)) if (args['x-api-key'] != null) headers.set("x-api-key", String(args['x-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };