diff --git a/src/components/sse.js b/src/components/sse.js index 80ad621..c2c2e56 100644 --- a/src/components/sse.js +++ b/src/components/sse.js @@ -46,6 +46,28 @@ export async function deleteGroup({secretKey, id}) { return response; } +export async function addUsersToGroup({secretKey, id, users}) { + const response = await server.loadJson( + `${ + Config.eventsApiUrl + }${Endpoints.PROJECT.NOTIFICATIONS.SERVER_EVENTS.ADD_USERS_TO_GROUP(id)}`, + { + method: 'POST', + headers: { + 'X-CM-ProjectId': Config.projectId, + Authorization: `Bearer ${secretKey || Config.secretKey}`, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + users, + }), + } + ); + + return response; +} + export async function getGroups({ secretKey, pageNumber, @@ -163,6 +185,31 @@ export async function deleteChannel({secretKey, groupId, id}) { return response; } +export async function addUsersToChannel({secretKey, groupId, id, users}) { + const response = await server.loadJson( + `${ + Config.eventsApiUrl + }${Endpoints.PROJECT.NOTIFICATIONS.SERVER_EVENTS.ADD_USERS_TO_CHANNEL( + groupId, + id + )}`, + { + method: 'POST', + headers: { + 'X-CM-ProjectId': Config.projectId, + Authorization: `Bearer ${secretKey || Config.secretKey}`, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + users, + }), + } + ); + + return response; +} + export async function getChannels({ secretKey, groupId, diff --git a/src/routes.js b/src/routes.js index 0e3fd1e..23e8470 100644 --- a/src/routes.js +++ b/src/routes.js @@ -76,12 +76,16 @@ export const CONFIG = { SERVER_EVENTS: { CREATE_GROUP: '/v2/notifications/server-events/groups', DELETE_GROUP: (id) => `/v2/notifications/server-events/groups/${id}`, + ADD_USERS_TO_GROUP: (id) => + `/v2/notifications/server-events/groups/${id}/users`, GET_GROUPS: '/v2/notifications/server-events/groups', GET_GROUP: (id) => `/v2/notifications/server-events/groups/${id}`, CREATE_CHANNEL: (groupId) => `/v2/notifications/server-events/groups/${groupId}/channels`, DELETE_CHANNEL: (groupId, id) => `/v2/notifications/server-events/groups/${groupId}/channels/${id}`, + ADD_USERS_TO_CHANNEL: (groupId, id) => + `/v2/notifications/server-events/groups/${groupId}/channels/${id}/users`, GET_CHANNELS: (groupId) => `/v2/notifications/server-events/groups/${groupId}/channels`, GET_MESSAGES: '/v2/notifications/server-events/messages',