export type ToggleUserStatusRequest = {activateUser?: boolean | undefined, userId?: (string | null) | undefined}; export type CreateApiApiVVersionUsersIdToggleStatusArgs = {version: string, id: string, 'X-Tenant': string, body: ToggleUserStatusRequest}; export type CreateApiApiVVersionUsersIdToggleStatusOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Toggle a user's active status * * POST /api/v{version}/users/{id}/toggle-status */ export const createApiApiVVersionUsersIdToggleStatus = async (args: CreateApiApiVVersionUsersIdToggleStatusArgs, options?: CreateApiApiVVersionUsersIdToggleStatusOptions) => { const {baseUrl = "https://api.zrexpress.app", fetch: fetchFn = fetch, bearerAuth, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Tenant'] != null) headers.set("X-Tenant", String(args['X-Tenant'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) if (apiKey !== undefined) headers.set("X-Api-Key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v${encodeURIComponent(String(args.version))}/users/${encodeURIComponent(String(args.id))}/toggle-status${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 };