export type GlobalControlGroupRequest = {request_id: string, file_url: string, action_type: 'add' | 'remove', updated_by: string}; export type UpdateApiGlobalControlGroupUsersArgs = {'MOE-APPKEY': string, body: GlobalControlGroupRequest}; export type UpdateApiGlobalControlGroupUsersOptions = {baseUrl?: string | undefined, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update Global Control Group * * PUT /global-control-group/users */ export const updateApiGlobalControlGroupUsers = async (args: UpdateApiGlobalControlGroupUsersArgs, options?: UpdateApiGlobalControlGroupUsersOptions) => { const {baseUrl = "https://api-01.moengage.com/core-services/v1", fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['MOE-APPKEY'] != null) headers.set("MOE-APPKEY", String(args['MOE-APPKEY'])) if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/global-control-group/users${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 undefined };