export type ScimPatchOperation = {op: 'replace', path?: string | undefined, value: unknown}; export type ScimPatchRequest = {schemas?: Array | undefined, Operations: Array}; export type PatchApiScimUsersUserUidArgs = {userUid: string, body: ScimPatchRequest}; export type PatchApiScimUsersUserUidOptions = {baseUrl?: string | undefined, scimToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update user * * PATCH /scim/Users/{userUid} */ export const patchApiScimUsersUserUid = async (args: PatchApiScimUsersUserUidArgs, options?: PatchApiScimUsersUserUidOptions) => { const {baseUrl = "https://eu.phrase.com/control-hub", fetch: fetchFn = fetch, scimToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (scimToken !== undefined) headers.set('authorization', `Bearer ${scimToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/scim/Users/${encodeURIComponent(String(args.userUid))}${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 };