export type CreateApiApiUserGroupsV1UserGroupIdRelationshipsUsersArgs = {user_group_id: string, body: {data?: (Array<{type?: 'ppms/user' | undefined, id?: string | undefined}>) | undefined}}; export type CreateApiApiUserGroupsV1UserGroupIdRelationshipsUsersOptions = {baseUrl?: string | undefined, OAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add users to user group * * POST /api/user-groups/v1/{user_group_id}/relationships/users */ export const createApiApiUserGroupsV1UserGroupIdRelationshipsUsers = async (args: CreateApiApiUserGroupsV1UserGroupIdRelationshipsUsersArgs, options?: CreateApiApiUserGroupsV1UserGroupIdRelationshipsUsersOptions) => { 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/user-groups/v1/${encodeURIComponent(String(args.user_group_id))}/relationships/users${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };