export type PatchApiApiUsersV2MeArgs = {body: {data: {id?: string | undefined, type?: 'ppms/user' | undefined, attributes?: ({role?: ('OWNER' | 'USER') | undefined, language?: unknown | undefined}) | undefined}}}; export type PatchApiApiUsersV2MeOptions = {baseUrl?: string | undefined, OAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Edit own account * * PATCH /api/users/v2/me */ export const patchApiApiUsersV2Me = async (args: PatchApiApiUsersV2MeArgs, options?: PatchApiApiUsersV2MeOptions) => { const {baseUrl = "https://example.piwik.pro", fetch: fetchFn = fetch, OAuth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") if (OAuth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${OAuth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/users/v2/me${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 };