@signalhousellc/sdk 1.0.42 → 1.0.44
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/README.md +38 -38
- package/package.json +1 -1
- package/src/domains/Auth.js +54 -54
- package/src/domains/Groups.js +90 -90
- package/src/domains/Landings.js +132 -132
- package/src/domains/Messages.js +65 -2
- package/src/domains/Notifications.js +56 -56
- package/src/domains/Shortlinks.js +44 -44
- package/src/domains/Subgroups.js +106 -106
- package/src/domains/Subscriptions.js +140 -140
- package/src/domains/Webhooks.js +74 -74
package/src/domains/Messages.js
CHANGED
|
@@ -100,6 +100,22 @@ export class Messages {
|
|
|
100
100
|
return this.client(`/message/analytics/detail${queryString}`, { method: "GET", ...options });
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Get filter dropdown options (subgroups, brands, campaigns, phone numbers) for the Analytics page,
|
|
105
|
+
* scoped to a single group. Sourced from ClickHouse — only items with at least one message are returned.
|
|
106
|
+
* @async
|
|
107
|
+
* @roles api, admin, developer, billing, user
|
|
108
|
+
* @param {Object} params - The parameters for getting analytics filter options
|
|
109
|
+
* @param {string} params.groupId - The ID of the group whose filter options to load
|
|
110
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
111
|
+
* @returns {Promise<Object>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers }
|
|
112
|
+
*/
|
|
113
|
+
async getAnalyticsFilterOptions({ groupId, options = {} }) {
|
|
114
|
+
const filters = { groupId };
|
|
115
|
+
const queryString = this.client._getQueryString(filters);
|
|
116
|
+
return this.client(`/message/analytics/filter-options${queryString}`, { method: "GET", ...options });
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
/**
|
|
104
120
|
* Get aggregated DNC (Do Not Contact) opt-out analytics with optional filters
|
|
105
121
|
* @async
|
|
@@ -158,14 +174,37 @@ export class Messages {
|
|
|
158
174
|
* @param {string} params.messageBody - The body of the SMS message
|
|
159
175
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
160
176
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
177
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
161
178
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
162
179
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
163
180
|
*/
|
|
164
|
-
async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, options = {} }) {
|
|
181
|
+
async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, filterLandlinesAndInactiveNumbers = false, options = {} }) {
|
|
165
182
|
this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
|
|
166
183
|
return this.client(`/message/sms`, {
|
|
167
184
|
method: "POST",
|
|
168
|
-
body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink },
|
|
185
|
+
body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink, ...(filterLandlinesAndInactiveNumbers && { filterLandlinesAndInactiveNumbers }) },
|
|
186
|
+
...options,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Send a P2P message via Rogue Mobile SMPP
|
|
192
|
+
* @async
|
|
193
|
+
* @roles api, admin, developer, billing, user
|
|
194
|
+
* @param {Object} params - The parameters for sending a P2P message
|
|
195
|
+
* @param {string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
|
|
196
|
+
* @param {string} params.messageBody - The body of the P2P message
|
|
197
|
+
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
198
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
199
|
+
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
200
|
+
*/
|
|
201
|
+
async sendP2P({ recipientPhoneNumbers, messageBody, statusCallbackUrl, options = {} }) {
|
|
202
|
+
this.client._require({ recipientPhoneNumbers, messageBody });
|
|
203
|
+
const body = { recipientPhoneNumber: recipientPhoneNumbers, messageBody };
|
|
204
|
+
if (statusCallbackUrl) body.statusCallbackUrl = statusCallbackUrl;
|
|
205
|
+
return this.client(`/message/p2p`, {
|
|
206
|
+
method: "POST",
|
|
207
|
+
body,
|
|
169
208
|
...options,
|
|
170
209
|
});
|
|
171
210
|
}
|
|
@@ -182,6 +221,7 @@ export class Messages {
|
|
|
182
221
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
183
222
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
184
223
|
* @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
|
|
224
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
185
225
|
* @param {File[]} [params.images] - The images to attach to the MMS message
|
|
186
226
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
187
227
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
@@ -194,6 +234,7 @@ export class Messages {
|
|
|
194
234
|
statusCallbackUrl,
|
|
195
235
|
enableShortlink = false,
|
|
196
236
|
enableCompression = true,
|
|
237
|
+
filterLandlinesAndInactiveNumbers = false,
|
|
197
238
|
images,
|
|
198
239
|
options = {},
|
|
199
240
|
}) {
|
|
@@ -222,6 +263,7 @@ export class Messages {
|
|
|
222
263
|
|
|
223
264
|
formData.append("enableShortlink", enableShortlink);
|
|
224
265
|
formData.append("enableCompression", enableCompression);
|
|
266
|
+
if (filterLandlinesAndInactiveNumbers) formData.append("filterLandlinesAndInactiveNumbers", filterLandlinesAndInactiveNumbers);
|
|
225
267
|
|
|
226
268
|
return this.multipartClient(`/message/mms`, { method: "POST", body: formData, ...options });
|
|
227
269
|
}
|
|
@@ -238,6 +280,7 @@ export class Messages {
|
|
|
238
280
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
239
281
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
240
282
|
* @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
|
|
283
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
241
284
|
* @param {File[]} [params.images] - The images to attach to the MMS message
|
|
242
285
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
243
286
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
@@ -250,6 +293,7 @@ export class Messages {
|
|
|
250
293
|
statusCallbackUrl,
|
|
251
294
|
enableShortlink = false,
|
|
252
295
|
enableCompression = true,
|
|
296
|
+
filterLandlinesAndInactiveNumbers = false,
|
|
253
297
|
images,
|
|
254
298
|
options = {},
|
|
255
299
|
}) {
|
|
@@ -278,7 +322,26 @@ export class Messages {
|
|
|
278
322
|
|
|
279
323
|
formData.append("enableShortlink", enableShortlink);
|
|
280
324
|
formData.append("enableCompression", enableCompression);
|
|
325
|
+
if (filterLandlinesAndInactiveNumbers) formData.append("filterLandlinesAndInactiveNumbers", filterLandlinesAndInactiveNumbers);
|
|
281
326
|
|
|
282
327
|
return this.multipartClient(`/message/groupMessage`, { method: "POST", body: formData, ...options });
|
|
283
328
|
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Look up the carrier for a phone number. Always performs a fresh lookup (not cached). Billed per request.
|
|
332
|
+
* @async
|
|
333
|
+
* @roles api, admin, developer, billing, user
|
|
334
|
+
* @param {Object} params - The parameters for looking up a carrier
|
|
335
|
+
* @param {string} params.phoneNumber - The phone number to look up (10+ digits, no + prefix)
|
|
336
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
337
|
+
* @returns {Promise<Object>} - A promise that resolves to carrier information
|
|
338
|
+
*/
|
|
339
|
+
async carrierIdLookup({ phoneNumber, options = {} }) {
|
|
340
|
+
this.client._require({ phoneNumber });
|
|
341
|
+
return this.client(`/message/carrier-id`, {
|
|
342
|
+
method: "POST",
|
|
343
|
+
body: { phoneNumber },
|
|
344
|
+
...options,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
284
347
|
}
|
|
@@ -1,56 +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(`/notification${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(`/notification/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(`/notification/${safeId}`, { method: "DELETE", ...options });
|
|
55
|
-
}
|
|
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(`/notification${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(`/notification/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(`/notification/${safeId}`, { method: "DELETE", ...options });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
export class Shortlinks {
|
|
2
|
-
constructor(client, enableAdmin) {
|
|
3
|
-
this.client = client;
|
|
4
|
-
this.enableAdmin = enableAdmin;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get the redirect URL for a shortlink by its ID
|
|
9
|
-
* @async
|
|
10
|
-
* @roles public
|
|
11
|
-
* @param {Object} params - The parameters for getting the shortlink redirect
|
|
12
|
-
* @param {string} params.shortlinkId - The ID of the shortlink
|
|
13
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
14
|
-
* @returns {Promise<Object>} A promise that resolves to the redirect URL for the shortlink
|
|
15
|
-
*/
|
|
16
|
-
async getShortlinkRedirect({ shortlinkId, options = {} }) {
|
|
17
|
-
this.client._require({ shortlinkId });
|
|
18
|
-
const safeShortlinkId = encodeURIComponent(shortlinkId);
|
|
19
|
-
return this.client(`/shortlink/redirect/${safeShortlinkId}`, { method: "GET", ...options });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Get details of a shortlink by its ID, with optional filters
|
|
24
|
-
* @async
|
|
25
|
-
* @roles api, admin, developer, billing, user
|
|
26
|
-
* @param {Object} params - The parameters for getting the shortlink details
|
|
27
|
-
* @param {string} [params.shortlinkId] - The ID of the shortlink
|
|
28
|
-
* @param {string} [params.messageId] - Filter by associated message ID
|
|
29
|
-
* @param {string} [params.phoneNumber] - Filter by associated phone number
|
|
30
|
-
* @param {string} [params.campaignId] - Filter by associated campaign ID
|
|
31
|
-
* @param {string} [params.brandId] - Filter by associated brand ID
|
|
32
|
-
* @param {string} [params.subgroupId] - Filter by associated subgroup ID
|
|
33
|
-
* @param {string} [params.groupId] - Filter by associated group ID
|
|
34
|
-
* @param {number} [params.page] - The page number for pagination
|
|
35
|
-
* @param {number} [params.limit] - The number of items per page for pagination
|
|
36
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
37
|
-
* @returns {Promise<Object>} A promise that resolves to the shortlink details
|
|
38
|
-
*/
|
|
39
|
-
async getShortlink({ shortlinkId, messageId, phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
40
|
-
const filters = { shortlinkId, messageId, phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit };
|
|
41
|
-
const queryString = this.client._getQueryString(filters);
|
|
42
|
-
return this.client(`/shortlink${queryString}`, { method: "GET", ...options });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
export class Shortlinks {
|
|
2
|
+
constructor(client, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.enableAdmin = enableAdmin;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get the redirect URL for a shortlink by its ID
|
|
9
|
+
* @async
|
|
10
|
+
* @roles public
|
|
11
|
+
* @param {Object} params - The parameters for getting the shortlink redirect
|
|
12
|
+
* @param {string} params.shortlinkId - The ID of the shortlink
|
|
13
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
14
|
+
* @returns {Promise<Object>} A promise that resolves to the redirect URL for the shortlink
|
|
15
|
+
*/
|
|
16
|
+
async getShortlinkRedirect({ shortlinkId, options = {} }) {
|
|
17
|
+
this.client._require({ shortlinkId });
|
|
18
|
+
const safeShortlinkId = encodeURIComponent(shortlinkId);
|
|
19
|
+
return this.client(`/shortlink/redirect/${safeShortlinkId}`, { method: "GET", ...options });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get details of a shortlink by its ID, with optional filters
|
|
24
|
+
* @async
|
|
25
|
+
* @roles api, admin, developer, billing, user
|
|
26
|
+
* @param {Object} params - The parameters for getting the shortlink details
|
|
27
|
+
* @param {string} [params.shortlinkId] - The ID of the shortlink
|
|
28
|
+
* @param {string} [params.messageId] - Filter by associated message ID
|
|
29
|
+
* @param {string} [params.phoneNumber] - Filter by associated phone number
|
|
30
|
+
* @param {string} [params.campaignId] - Filter by associated campaign ID
|
|
31
|
+
* @param {string} [params.brandId] - Filter by associated brand ID
|
|
32
|
+
* @param {string} [params.subgroupId] - Filter by associated subgroup ID
|
|
33
|
+
* @param {string} [params.groupId] - Filter by associated group ID
|
|
34
|
+
* @param {number} [params.page] - The page number for pagination
|
|
35
|
+
* @param {number} [params.limit] - The number of items per page for pagination
|
|
36
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
37
|
+
* @returns {Promise<Object>} A promise that resolves to the shortlink details
|
|
38
|
+
*/
|
|
39
|
+
async getShortlink({ shortlinkId, messageId, phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
40
|
+
const filters = { shortlinkId, messageId, phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit };
|
|
41
|
+
const queryString = this.client._getQueryString(filters);
|
|
42
|
+
return this.client(`/shortlink${queryString}`, { method: "GET", ...options });
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/domains/Subgroups.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} CreateSubgroupData
|
|
3
|
-
* @property {string} groupId - The ID of the parent group for the subgroup (must be at least 8 characters long and start with 'G')
|
|
4
|
-
* @property {string} subgroupName - The name of the subgroup (required)
|
|
5
|
-
* @property {string} [contactFirstName] - The first name of the contact person for the subgroup
|
|
6
|
-
* @property {string} [contactLastName] - The last name of the contact person for the subgroup
|
|
7
|
-
* @property {string} [contactMiddleName] - The middle name of the contact person for the subgroup
|
|
8
|
-
* @property {string} [subgroupCompanyName] - The company name associated with the subgroup
|
|
9
|
-
* @property {string} [addressLine1] - The first line of the address for the subgroup
|
|
10
|
-
* @property {string} [addressLine2] - The second line of the address for the subgroup
|
|
11
|
-
* @property {string} [city] - The city for the subgroup's address
|
|
12
|
-
* @property {string} [state] - The state for the subgroup's address
|
|
13
|
-
* @property {string} [country] - The country for the subgroup's address
|
|
14
|
-
* @property {string} [postalCode] - The postal code for the subgroup's address
|
|
15
|
-
* @property {string} [phone] - The phone number for the subgroup
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} UpdateSubgroupData
|
|
20
|
-
* @property {string} [subgroupName] - The name of the subgroup
|
|
21
|
-
* @property {string} [contactFirstName] - The first name of the contact person for the subgroup
|
|
22
|
-
* @property {string} [contactLastName] - The last name of the contact person for the subgroup
|
|
23
|
-
* @property {string} [contactMiddleName] - The middle name of the contact person for the subgroup
|
|
24
|
-
* @property {string} [subgroupCompanyName] - The company name associated with the subgroup
|
|
25
|
-
* @property {string} [addressLine1] - The first line of the address for the subgroup
|
|
26
|
-
* @property {string} [addressLine2] - The second line of the address for the subgroup
|
|
27
|
-
* @property {string} [city] - The city for the subgroup's address
|
|
28
|
-
* @property {string} [state] - The state for the subgroup's address
|
|
29
|
-
* @property {string} [country] - The country for the subgroup's address
|
|
30
|
-
* @property {string} [postalCode] - The postal code for the subgroup's address
|
|
31
|
-
* @property {string} [phone] - The phone number for the subgroup
|
|
32
|
-
* @property {string} [status] - The status of the subgroup (e.g., "active", "inactive")
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
export class Subgroups {
|
|
36
|
-
constructor(client, enableAdmin) {
|
|
37
|
-
this.client = client;
|
|
38
|
-
this.enableAdmin = enableAdmin;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get a list of subgroups with optional filters
|
|
43
|
-
* @async
|
|
44
|
-
* @roles api, admin, developer, billing, user
|
|
45
|
-
* @param {Object} params - The parameters for getting subgroups
|
|
46
|
-
* @param {string} [params.id] - Filter by subgroup ID
|
|
47
|
-
* @param {string} [params.groupId] - Filter by parent group ID
|
|
48
|
-
* @param {number} [params.page] - The page number for pagination
|
|
49
|
-
* @param {number} [params.limit] - The number of items per page for pagination
|
|
50
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
51
|
-
* @returns {Promise<Object>} - The list of subgroups returned from the server
|
|
52
|
-
*/
|
|
53
|
-
async getSubgroups({ id, groupId, page, limit, options = {} }) {
|
|
54
|
-
const filters = { id, groupId, page, limit };
|
|
55
|
-
const queryString = this.client._getQueryString(filters);
|
|
56
|
-
return this.client(`/subgroup${queryString}`, { method: "GET", ...options });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Create a new subgroup with the specified subgroup data
|
|
61
|
-
* @async
|
|
62
|
-
* @roles api, admin, developer, billing, user
|
|
63
|
-
* @param {Object} params - The parameters for creating a subgroup (see CreateSubgroupData typedef for details)
|
|
64
|
-
* @param {CreateSubgroupData} params.subgroupData - The data for the subgroup to be created, including required fields such as groupId and subgroupName
|
|
65
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
66
|
-
* @throws {Error} Throws an error if the subgroupData parameter is missing or if required fields in subgroupData are missing
|
|
67
|
-
* @returns {Promise<Object>} - The created subgroup object returned from the server
|
|
68
|
-
*/
|
|
69
|
-
async createSubgroup({ subgroupData, options = {} }) {
|
|
70
|
-
this.client._require({ subgroupData: subgroupData });
|
|
71
|
-
return this.client(`/subgroup`, { method: "POST", body: subgroupData, ...options });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Update an existing subgroup with the specified subgroup data
|
|
76
|
-
* @async
|
|
77
|
-
* @roles api, admin, developer, billing, user
|
|
78
|
-
* @param {Object} params - The parameters for updating a subgroup (see UpdateSubgroupData typedef for details)
|
|
79
|
-
* @param {string} params.id - The ID of the subgroup to update
|
|
80
|
-
* @param {UpdateSubgroupData} params.updateData - The data for the subgroup to be updated, including fields such as subgroupName, contact information, and status
|
|
81
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
82
|
-
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
83
|
-
* @returns {Promise<Object>} - The updated subgroup object returned from the server
|
|
84
|
-
*/
|
|
85
|
-
async updateSubgroup({ id, updateData, options = {} }) {
|
|
86
|
-
this.client._require({ id, updateData });
|
|
87
|
-
const safeId = encodeURIComponent(id);
|
|
88
|
-
return this.client(`/subgroup/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Delete a subgroup by its ID (mark as inactive)
|
|
93
|
-
* @async
|
|
94
|
-
* @roles api, admin, developer, billing, user
|
|
95
|
-
* @param {Object} params - The parameters for deleting a subgroup
|
|
96
|
-
* @param {string} params.id - The ID of the subgroup to delete
|
|
97
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
98
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
99
|
-
* @returns {Promise<Object>} - The deleted subgroup object returned from the server
|
|
100
|
-
*/
|
|
101
|
-
async deleteSubgroup({ id, options = {} }) {
|
|
102
|
-
this.client._require({ id });
|
|
103
|
-
const safeId = encodeURIComponent(id);
|
|
104
|
-
return this.client(`/subgroup/${safeId}`, { method: "DELETE", ...options });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} CreateSubgroupData
|
|
3
|
+
* @property {string} groupId - The ID of the parent group for the subgroup (must be at least 8 characters long and start with 'G')
|
|
4
|
+
* @property {string} subgroupName - The name of the subgroup (required)
|
|
5
|
+
* @property {string} [contactFirstName] - The first name of the contact person for the subgroup
|
|
6
|
+
* @property {string} [contactLastName] - The last name of the contact person for the subgroup
|
|
7
|
+
* @property {string} [contactMiddleName] - The middle name of the contact person for the subgroup
|
|
8
|
+
* @property {string} [subgroupCompanyName] - The company name associated with the subgroup
|
|
9
|
+
* @property {string} [addressLine1] - The first line of the address for the subgroup
|
|
10
|
+
* @property {string} [addressLine2] - The second line of the address for the subgroup
|
|
11
|
+
* @property {string} [city] - The city for the subgroup's address
|
|
12
|
+
* @property {string} [state] - The state for the subgroup's address
|
|
13
|
+
* @property {string} [country] - The country for the subgroup's address
|
|
14
|
+
* @property {string} [postalCode] - The postal code for the subgroup's address
|
|
15
|
+
* @property {string} [phone] - The phone number for the subgroup
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} UpdateSubgroupData
|
|
20
|
+
* @property {string} [subgroupName] - The name of the subgroup
|
|
21
|
+
* @property {string} [contactFirstName] - The first name of the contact person for the subgroup
|
|
22
|
+
* @property {string} [contactLastName] - The last name of the contact person for the subgroup
|
|
23
|
+
* @property {string} [contactMiddleName] - The middle name of the contact person for the subgroup
|
|
24
|
+
* @property {string} [subgroupCompanyName] - The company name associated with the subgroup
|
|
25
|
+
* @property {string} [addressLine1] - The first line of the address for the subgroup
|
|
26
|
+
* @property {string} [addressLine2] - The second line of the address for the subgroup
|
|
27
|
+
* @property {string} [city] - The city for the subgroup's address
|
|
28
|
+
* @property {string} [state] - The state for the subgroup's address
|
|
29
|
+
* @property {string} [country] - The country for the subgroup's address
|
|
30
|
+
* @property {string} [postalCode] - The postal code for the subgroup's address
|
|
31
|
+
* @property {string} [phone] - The phone number for the subgroup
|
|
32
|
+
* @property {string} [status] - The status of the subgroup (e.g., "active", "inactive")
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export class Subgroups {
|
|
36
|
+
constructor(client, enableAdmin) {
|
|
37
|
+
this.client = client;
|
|
38
|
+
this.enableAdmin = enableAdmin;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get a list of subgroups with optional filters
|
|
43
|
+
* @async
|
|
44
|
+
* @roles api, admin, developer, billing, user
|
|
45
|
+
* @param {Object} params - The parameters for getting subgroups
|
|
46
|
+
* @param {string} [params.id] - Filter by subgroup ID
|
|
47
|
+
* @param {string} [params.groupId] - Filter by parent group ID
|
|
48
|
+
* @param {number} [params.page] - The page number for pagination
|
|
49
|
+
* @param {number} [params.limit] - The number of items per page for pagination
|
|
50
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
51
|
+
* @returns {Promise<Object>} - The list of subgroups returned from the server
|
|
52
|
+
*/
|
|
53
|
+
async getSubgroups({ id, groupId, page, limit, options = {} }) {
|
|
54
|
+
const filters = { id, groupId, page, limit };
|
|
55
|
+
const queryString = this.client._getQueryString(filters);
|
|
56
|
+
return this.client(`/subgroup${queryString}`, { method: "GET", ...options });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create a new subgroup with the specified subgroup data
|
|
61
|
+
* @async
|
|
62
|
+
* @roles api, admin, developer, billing, user
|
|
63
|
+
* @param {Object} params - The parameters for creating a subgroup (see CreateSubgroupData typedef for details)
|
|
64
|
+
* @param {CreateSubgroupData} params.subgroupData - The data for the subgroup to be created, including required fields such as groupId and subgroupName
|
|
65
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
66
|
+
* @throws {Error} Throws an error if the subgroupData parameter is missing or if required fields in subgroupData are missing
|
|
67
|
+
* @returns {Promise<Object>} - The created subgroup object returned from the server
|
|
68
|
+
*/
|
|
69
|
+
async createSubgroup({ subgroupData, options = {} }) {
|
|
70
|
+
this.client._require({ subgroupData: subgroupData });
|
|
71
|
+
return this.client(`/subgroup`, { method: "POST", body: subgroupData, ...options });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Update an existing subgroup with the specified subgroup data
|
|
76
|
+
* @async
|
|
77
|
+
* @roles api, admin, developer, billing, user
|
|
78
|
+
* @param {Object} params - The parameters for updating a subgroup (see UpdateSubgroupData typedef for details)
|
|
79
|
+
* @param {string} params.id - The ID of the subgroup to update
|
|
80
|
+
* @param {UpdateSubgroupData} params.updateData - The data for the subgroup to be updated, including fields such as subgroupName, contact information, and status
|
|
81
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
82
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
83
|
+
* @returns {Promise<Object>} - The updated subgroup object returned from the server
|
|
84
|
+
*/
|
|
85
|
+
async updateSubgroup({ id, updateData, options = {} }) {
|
|
86
|
+
this.client._require({ id, updateData });
|
|
87
|
+
const safeId = encodeURIComponent(id);
|
|
88
|
+
return this.client(`/subgroup/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Delete a subgroup by its ID (mark as inactive)
|
|
93
|
+
* @async
|
|
94
|
+
* @roles api, admin, developer, billing, user
|
|
95
|
+
* @param {Object} params - The parameters for deleting a subgroup
|
|
96
|
+
* @param {string} params.id - The ID of the subgroup to delete
|
|
97
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
98
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
99
|
+
* @returns {Promise<Object>} - The deleted subgroup object returned from the server
|
|
100
|
+
*/
|
|
101
|
+
async deleteSubgroup({ id, options = {} }) {
|
|
102
|
+
this.client._require({ id });
|
|
103
|
+
const safeId = encodeURIComponent(id);
|
|
104
|
+
return this.client(`/subgroup/${safeId}`, { method: "DELETE", ...options });
|
|
105
|
+
}
|
|
106
|
+
}
|