export type UpdateApiApiModulesV1AccessUserUserIdArgs = {user_id: string, body: {data: Array<{type: 'module/access', id: 'analytics' | 'consent_manager' | 'customer_data_platform' | 'tag_manager' | 'administration', attributes: {access: boolean}}>}}; export type UpdateApiApiModulesV1AccessUserUserIdOptions = {baseUrl?: string | undefined, OAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set modules access for a given user * * PUT /api/modules/v1/access/user/{user_id} */ export const updateApiApiModulesV1AccessUserUserId = async (args: UpdateApiApiModulesV1AccessUserUserIdArgs, options?: UpdateApiApiModulesV1AccessUserUserIdOptions) => { 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") headers.set('accept', "*/*") if (OAuth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${OAuth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/modules/v1/access/user/${encodeURIComponent(String(args.user_id))}${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 res.blob() };