@signalhousellc/sdk 1.0.44 → 1.0.45
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/Notifications.js +56 -56
- package/src/domains/Onboarding.js +27 -0
- 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
|
@@ -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
|
+
}
|
|
@@ -36,4 +36,31 @@ export class Onboarding {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the caller's own onboarding record (customer-safe projection).
|
|
42
|
+
* Returns `{ acceptedTermsOfService: boolean }`.
|
|
43
|
+
* @async
|
|
44
|
+
* @param {Object} [params] - Optional parameters
|
|
45
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
46
|
+
* @returns {Promise<Object>} - `{ acceptedTermsOfService: boolean }`
|
|
47
|
+
*/
|
|
48
|
+
async getMyOnboarding({ options = {} } = {}) {
|
|
49
|
+
return this.client(`/group/onboarding/my`, { method: "GET", ...options });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Accept the Terms of Service for the caller's active group.
|
|
54
|
+
* @async
|
|
55
|
+
* @param {Object} [params] - Optional parameters
|
|
56
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
57
|
+
* @returns {Promise<Object>} - `{ acceptedTermsOfService: true }`
|
|
58
|
+
*/
|
|
59
|
+
async acceptTermsOfService({ options = {} } = {}) {
|
|
60
|
+
return this.client(`/group/onboarding/my/accept-terms`, {
|
|
61
|
+
method: "PUT",
|
|
62
|
+
body: { acceptedTermsOfService: true },
|
|
63
|
+
...options,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
39
66
|
}
|
|
@@ -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
|
+
}
|