export type ProfileUpdate = {name: string}; export type PatchApiApiV3UserProfileArgs = {body: ProfileUpdate}; export type PatchApiApiV3UserProfileOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update profile of the authenticated user * * PATCH /api/v3/user/profile */ export const patchApiApiV3UserProfile = async (args: PatchApiApiV3UserProfileArgs, options?: PatchApiApiV3UserProfileOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/user/profile${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 };