export type User = {alias: string, first_name?: string | undefined, last_name?: string | undefined, email: string, profile_image_id?: string | undefined, password_set: boolean, tfa_enabled?: boolean | undefined}; export type UpdateApiUsersProfileArgs = {body: User}; export type UpdateApiUsersProfileOptions = {baseUrl: string, ApiKeyId?: string | undefined, ApiKeySecret?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update user's profile * * PUT /users/profile */ export const updateApiUsersProfile = async (args: UpdateApiUsersProfileArgs, options: UpdateApiUsersProfileOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyId, ApiKeySecret} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyId !== undefined) headers.set("X-API-KEY-ID", ApiKeyId) if (ApiKeySecret !== undefined) headers.set("X-API-KEY-SECRET", ApiKeySecret) const url = `${baseUrl.replace(/\/+$/, '')}/users/profile${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };