@signalhousellc/sdk 1.0.42 → 1.0.43
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 +27 -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
|
@@ -158,14 +158,15 @@ export class Messages {
|
|
|
158
158
|
* @param {string} params.messageBody - The body of the SMS message
|
|
159
159
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
160
160
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
161
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
161
162
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
162
163
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
163
164
|
*/
|
|
164
|
-
async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, options = {} }) {
|
|
165
|
+
async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, filterLandlinesAndInactiveNumbers = false, options = {} }) {
|
|
165
166
|
this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
|
|
166
167
|
return this.client(`/message/sms`, {
|
|
167
168
|
method: "POST",
|
|
168
|
-
body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink },
|
|
169
|
+
body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink, ...(filterLandlinesAndInactiveNumbers && { filterLandlinesAndInactiveNumbers }) },
|
|
169
170
|
...options,
|
|
170
171
|
});
|
|
171
172
|
}
|
|
@@ -182,6 +183,7 @@ export class Messages {
|
|
|
182
183
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
183
184
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
184
185
|
* @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
|
|
186
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
185
187
|
* @param {File[]} [params.images] - The images to attach to the MMS message
|
|
186
188
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
187
189
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
@@ -194,6 +196,7 @@ export class Messages {
|
|
|
194
196
|
statusCallbackUrl,
|
|
195
197
|
enableShortlink = false,
|
|
196
198
|
enableCompression = true,
|
|
199
|
+
filterLandlinesAndInactiveNumbers = false,
|
|
197
200
|
images,
|
|
198
201
|
options = {},
|
|
199
202
|
}) {
|
|
@@ -222,6 +225,7 @@ export class Messages {
|
|
|
222
225
|
|
|
223
226
|
formData.append("enableShortlink", enableShortlink);
|
|
224
227
|
formData.append("enableCompression", enableCompression);
|
|
228
|
+
if (filterLandlinesAndInactiveNumbers) formData.append("filterLandlinesAndInactiveNumbers", filterLandlinesAndInactiveNumbers);
|
|
225
229
|
|
|
226
230
|
return this.multipartClient(`/message/mms`, { method: "POST", body: formData, ...options });
|
|
227
231
|
}
|
|
@@ -238,6 +242,7 @@ export class Messages {
|
|
|
238
242
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
239
243
|
* @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
|
|
240
244
|
* @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
|
|
245
|
+
* @param {boolean} [params.filterLandlinesAndInactiveNumbers=false] - Whether to filter out landline and inactive numbers before sending
|
|
241
246
|
* @param {File[]} [params.images] - The images to attach to the MMS message
|
|
242
247
|
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
243
248
|
* @returns {Promise<Object>} - A promise that resolves to the response data from the server
|
|
@@ -250,6 +255,7 @@ export class Messages {
|
|
|
250
255
|
statusCallbackUrl,
|
|
251
256
|
enableShortlink = false,
|
|
252
257
|
enableCompression = true,
|
|
258
|
+
filterLandlinesAndInactiveNumbers = false,
|
|
253
259
|
images,
|
|
254
260
|
options = {},
|
|
255
261
|
}) {
|
|
@@ -278,7 +284,26 @@ export class Messages {
|
|
|
278
284
|
|
|
279
285
|
formData.append("enableShortlink", enableShortlink);
|
|
280
286
|
formData.append("enableCompression", enableCompression);
|
|
287
|
+
if (filterLandlinesAndInactiveNumbers) formData.append("filterLandlinesAndInactiveNumbers", filterLandlinesAndInactiveNumbers);
|
|
281
288
|
|
|
282
289
|
return this.multipartClient(`/message/groupMessage`, { method: "POST", body: formData, ...options });
|
|
283
290
|
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Look up the carrier for a phone number. Always performs a fresh lookup (not cached). Billed per request.
|
|
294
|
+
* @async
|
|
295
|
+
* @roles api, admin, developer, billing, user
|
|
296
|
+
* @param {Object} params - The parameters for looking up a carrier
|
|
297
|
+
* @param {string} params.phoneNumber - The phone number to look up (10+ digits, no + prefix)
|
|
298
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
299
|
+
* @returns {Promise<Object>} - A promise that resolves to carrier information
|
|
300
|
+
*/
|
|
301
|
+
async carrierIdLookup({ phoneNumber, options = {} }) {
|
|
302
|
+
this.client._require({ phoneNumber });
|
|
303
|
+
return this.client(`/message/carrier-id`, {
|
|
304
|
+
method: "POST",
|
|
305
|
+
body: { phoneNumber },
|
|
306
|
+
...options,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
284
309
|
}
|
|
@@ -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
|
+
}
|