@signalhousellc/sdk 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/SignalHouseSDK.js +2 -0
- package/src/domains/Notifications.js +56 -0
- package/src/domains/Users.js +31 -0
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -19,6 +19,7 @@ import { Shortlinks } from "./domains/Shortlinks.js";
|
|
|
19
19
|
import { Subgroups } from "./domains/Subgroups.js";
|
|
20
20
|
import { Subscriptions } from "./domains/Subscriptions.js";
|
|
21
21
|
import { Users } from "./domains/Users.js";
|
|
22
|
+
import { Notifications } from "./domains/Notifications.js";
|
|
22
23
|
import { Webhooks } from "./domains/Webhooks.js";
|
|
23
24
|
|
|
24
25
|
export class SignalHouseSDK {
|
|
@@ -61,6 +62,7 @@ export class SignalHouseSDK {
|
|
|
61
62
|
this.subgroups = new Subgroups(client, this.enableAdmin);
|
|
62
63
|
this.subscriptions = new Subscriptions(client, this.enableAdmin);
|
|
63
64
|
this.users = new Users(client, this.enableAdmin);
|
|
65
|
+
this.notifications = new Notifications(client, this.enableAdmin);
|
|
64
66
|
this.webhooks = new Webhooks(client, this.enableAdmin);
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class Notifications {
|
|
2
|
+
constructor(client, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.enableAdmin = enableAdmin;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get notifications by id or by groupId with optional filters
|
|
9
|
+
* @async
|
|
10
|
+
* @roles signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, billing, user
|
|
11
|
+
* @param {Object} params
|
|
12
|
+
* @param {string} [params.id] - Notification id (one of id/groupId required)
|
|
13
|
+
* @param {string} [params.groupId] - Group id to fetch notifications for (one of id/groupId required)
|
|
14
|
+
* @param {number} [params.page] - Page number (min 1, default 1)
|
|
15
|
+
* @param {number} [params.limit] - Results per page (min 1, max 100, default 10)
|
|
16
|
+
* @param {string} [params.status] - Filter by status: "READ" or "UNREAD"
|
|
17
|
+
* @param {string|string[]} [params.eventTypes] - Event types to filter by (comma-separated string or array)
|
|
18
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
19
|
+
* @returns {Promise<Object>} The response from the server
|
|
20
|
+
*/
|
|
21
|
+
async getNotifications({ id, groupId, page, limit, status, eventTypes, options = {} }) {
|
|
22
|
+
this.client._require({ "id or groupId": id ?? groupId });
|
|
23
|
+
const queryString = this.client._getQueryString({ id, groupId, page, limit, status, eventTypes });
|
|
24
|
+
return this.client(`/notifications${queryString}`, { method: "GET", ...options });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Update the status of one or more notifications
|
|
29
|
+
* @async
|
|
30
|
+
* @roles signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, billing, user
|
|
31
|
+
* @param {Object} params
|
|
32
|
+
* @param {string|string[]} params.ids - Notification id or array of notification ids
|
|
33
|
+
* @param {string} params.status - New status: "READ" or "UNREAD"
|
|
34
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
35
|
+
* @returns {Promise<Object>} The response from the server
|
|
36
|
+
*/
|
|
37
|
+
async updateNotificationStatus({ ids, status, options = {} }) {
|
|
38
|
+
this.client._require({ ids, status });
|
|
39
|
+
return this.client(`/notifications/status`, { method: "PUT", body: { ids, status }, ...options });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Delete a notification by id
|
|
44
|
+
* @async
|
|
45
|
+
* @roles signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, billing, user
|
|
46
|
+
* @param {Object} params
|
|
47
|
+
* @param {string} params.id - The notification id to delete
|
|
48
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
49
|
+
* @returns {Promise<Object>} The response from the server
|
|
50
|
+
*/
|
|
51
|
+
async deleteNotification({ id, options = {} }) {
|
|
52
|
+
this.client._require({ id });
|
|
53
|
+
const safeId = encodeURIComponent(id);
|
|
54
|
+
return this.client(`/notifications/${safeId}`, { method: "DELETE", ...options });
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/domains/Users.js
CHANGED
|
@@ -160,4 +160,35 @@ export class Users {
|
|
|
160
160
|
const safeId = encodeURIComponent(id);
|
|
161
161
|
return this.client(`/user/${safeId}`, { method: "DELETE", ...options });
|
|
162
162
|
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Get notification preferences for a user
|
|
166
|
+
* @async
|
|
167
|
+
* @roles api, admin, self
|
|
168
|
+
* @param {Object} params
|
|
169
|
+
* @param {string} params.id - The ID of the user
|
|
170
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
171
|
+
* @returns {Promise<Object>} The response from the server
|
|
172
|
+
*/
|
|
173
|
+
async getNotificationPreferences({ id, options = {} }) {
|
|
174
|
+
this.client._require({ id });
|
|
175
|
+
const safeId = encodeURIComponent(id);
|
|
176
|
+
return this.client(`/user/${safeId}/notification-preferences`, { method: "GET", ...options });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Update notification preferences for a user
|
|
181
|
+
* @async
|
|
182
|
+
* @roles api, admin, self
|
|
183
|
+
* @param {Object} params
|
|
184
|
+
* @param {string} params.id - The ID of the user
|
|
185
|
+
* @param {Array<{name: string, web: boolean, email: boolean}>} params.notificationPreferences - Array of notification preference objects
|
|
186
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
187
|
+
* @returns {Promise<Object>} The response from the server
|
|
188
|
+
*/
|
|
189
|
+
async updateNotificationPreferences({ id, notificationPreferences, options = {} }) {
|
|
190
|
+
this.client._require({ id, notificationPreferences });
|
|
191
|
+
const safeId = encodeURIComponent(id);
|
|
192
|
+
return this.client(`/user/${safeId}/notification-preferences`, { method: "PUT", body: { notificationPreferences }, ...options });
|
|
193
|
+
}
|
|
163
194
|
}
|