Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/components/sse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down