@signalhousellc/sdk 1.0.46 → 1.0.48
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/Billing.js +20 -0
- package/src/domains/Campaigns.js +17 -0
- package/src/domains/Groups.js +90 -90
- package/src/domains/Landings.js +132 -132
- package/src/domains/Messages.js +1 -1
- package/src/domains/Notifications.js +56 -56
- package/src/domains/Shortlinks.js +44 -44
- package/src/domains/Subgroups.js +110 -106
- package/src/domains/Subscriptions.js +140 -140
- package/src/domains/Webhooks.js +74 -74
package/src/domains/Subgroups.js
CHANGED
|
@@ -1,106 +1,110 @@
|
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
* @
|
|
22
|
-
* @property {string} [
|
|
23
|
-
* @property {string} [
|
|
24
|
-
* @property {string} [
|
|
25
|
-
* @property {string} [
|
|
26
|
-
* @property {string} [
|
|
27
|
-
* @property {string} [
|
|
28
|
-
* @property {string} [
|
|
29
|
-
* @property {string} [
|
|
30
|
-
* @property {string} [
|
|
31
|
-
* @property {string} [
|
|
32
|
-
* @property {string} [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {
|
|
51
|
-
* @
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
98
|
-
* @
|
|
99
|
-
* @
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
* @property {string} [carrierIdFamily] - Optional agency-managed carrier ID selection ("Default", "ATT", "TMobile", "Verizon", "USCellular", "GoogleVoice", "ClearSky", "Interop"). Setting this field requires signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, or billing role.
|
|
17
|
+
* @property {string|null} [carrierIdRegion] - Optional ClearSky region ("PRClaro", "GuamDocomo", "GuamGTA", "GuamITE") or null; only valid when carrierIdFamily is "ClearSky". Setting this field requires signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, or billing role.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} UpdateSubgroupData
|
|
22
|
+
* @property {string} [subgroupName] - The name of the subgroup
|
|
23
|
+
* @property {string} [contactFirstName] - The first name of the contact person for the subgroup
|
|
24
|
+
* @property {string} [contactLastName] - The last name of the contact person for the subgroup
|
|
25
|
+
* @property {string} [contactMiddleName] - The middle name of the contact person for the subgroup
|
|
26
|
+
* @property {string} [subgroupCompanyName] - The company name associated with the subgroup
|
|
27
|
+
* @property {string} [addressLine1] - The first line of the address for the subgroup
|
|
28
|
+
* @property {string} [addressLine2] - The second line of the address for the subgroup
|
|
29
|
+
* @property {string} [city] - The city for the subgroup's address
|
|
30
|
+
* @property {string} [state] - The state for the subgroup's address
|
|
31
|
+
* @property {string} [country] - The country for the subgroup's address
|
|
32
|
+
* @property {string} [postalCode] - The postal code for the subgroup's address
|
|
33
|
+
* @property {string} [phone] - The phone number for the subgroup
|
|
34
|
+
* @property {string} [status] - The status of the subgroup (e.g., "active", "inactive")
|
|
35
|
+
* @property {string} [carrierIdFamily] - Optional agency-managed carrier ID selection ("Default", "ATT", "TMobile", "Verizon", "USCellular", "GoogleVoice", "ClearSky", "Interop"). Setting this field requires signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, or billing role.
|
|
36
|
+
* @property {string|null} [carrierIdRegion] - Optional ClearSky region ("PRClaro", "GuamDocomo", "GuamGTA", "GuamITE") or null; only valid when carrierIdFamily is "ClearSky". Setting this field requires signalhouse_api, signalhouse_admin, signalhouse_user, api, admin, developer, or billing role.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export class Subgroups {
|
|
40
|
+
constructor(client, enableAdmin) {
|
|
41
|
+
this.client = client;
|
|
42
|
+
this.enableAdmin = enableAdmin;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get a list of subgroups with optional filters
|
|
47
|
+
* @async
|
|
48
|
+
* @roles api, admin, developer, billing, user
|
|
49
|
+
* @param {Object} params - The parameters for getting subgroups
|
|
50
|
+
* @param {string} [params.id] - Filter by subgroup ID
|
|
51
|
+
* @param {string} [params.groupId] - Filter by parent group ID
|
|
52
|
+
* @param {number} [params.page] - The page number for pagination
|
|
53
|
+
* @param {number} [params.limit] - The number of items per page for pagination
|
|
54
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
55
|
+
* @returns {Promise<Object>} - The list of subgroups returned from the server
|
|
56
|
+
*/
|
|
57
|
+
async getSubgroups({ id, groupId, page, limit, options = {} }) {
|
|
58
|
+
const filters = { id, groupId, page, limit };
|
|
59
|
+
const queryString = this.client._getQueryString(filters);
|
|
60
|
+
return this.client(`/subgroup${queryString}`, { method: "GET", ...options });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create a new subgroup with the specified subgroup data
|
|
65
|
+
* @async
|
|
66
|
+
* @roles api, admin, developer, billing, user
|
|
67
|
+
* @param {Object} params - The parameters for creating a subgroup (see CreateSubgroupData typedef for details)
|
|
68
|
+
* @param {CreateSubgroupData} params.subgroupData - The data for the subgroup to be created, including required fields such as groupId and subgroupName
|
|
69
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
70
|
+
* @throws {Error} Throws an error if the subgroupData parameter is missing or if required fields in subgroupData are missing
|
|
71
|
+
* @returns {Promise<Object>} - The created subgroup object returned from the server
|
|
72
|
+
*/
|
|
73
|
+
async createSubgroup({ subgroupData, options = {} }) {
|
|
74
|
+
this.client._require({ subgroupData: subgroupData });
|
|
75
|
+
return this.client(`/subgroup`, { method: "POST", body: subgroupData, ...options });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Update an existing subgroup with the specified subgroup data
|
|
80
|
+
* @async
|
|
81
|
+
* @roles api, admin, developer, billing, user
|
|
82
|
+
* @param {Object} params - The parameters for updating a subgroup (see UpdateSubgroupData typedef for details)
|
|
83
|
+
* @param {string} params.id - The ID of the subgroup to update
|
|
84
|
+
* @param {UpdateSubgroupData} params.updateData - The data for the subgroup to be updated, including fields such as subgroupName, contact information, and status
|
|
85
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
86
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
87
|
+
* @returns {Promise<Object>} - The updated subgroup object returned from the server
|
|
88
|
+
*/
|
|
89
|
+
async updateSubgroup({ id, updateData, options = {} }) {
|
|
90
|
+
this.client._require({ id, updateData });
|
|
91
|
+
const safeId = encodeURIComponent(id);
|
|
92
|
+
return this.client(`/subgroup/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Delete a subgroup by its ID (mark as inactive)
|
|
97
|
+
* @async
|
|
98
|
+
* @roles api, admin, developer, billing, user
|
|
99
|
+
* @param {Object} params - The parameters for deleting a subgroup
|
|
100
|
+
* @param {string} params.id - The ID of the subgroup to delete
|
|
101
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
102
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
103
|
+
* @returns {Promise<Object>} - The deleted subgroup object returned from the server
|
|
104
|
+
*/
|
|
105
|
+
async deleteSubgroup({ id, options = {} }) {
|
|
106
|
+
this.client._require({ id });
|
|
107
|
+
const safeId = encodeURIComponent(id);
|
|
108
|
+
return this.client(`/subgroup/${safeId}`, { method: "DELETE", ...options });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
export class Subscriptions {
|
|
2
|
-
constructor(client, enableAdmin) {
|
|
3
|
-
this.client = client;
|
|
4
|
-
this.enableAdmin = enableAdmin;
|
|
5
|
-
|
|
6
|
-
if (enableAdmin) {
|
|
7
|
-
this.admin = {
|
|
8
|
-
/**
|
|
9
|
-
* Get subscription templates with optional filtering by template ID
|
|
10
|
-
* @async
|
|
11
|
-
* @roles signalhouse
|
|
12
|
-
* @param {Object} params - The parameters for getting subscription templates
|
|
13
|
-
* @param {string} [params.templateId] - The ID of a specific template to retrieve (optional)
|
|
14
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
15
|
-
* @returns {Promise<Object>} - The subscription templates returned from the server
|
|
16
|
-
*/
|
|
17
|
-
getTemplates: async ({ templateId, options = {} }) => {
|
|
18
|
-
const filters = { templateId };
|
|
19
|
-
const queryString = this.client._getQueryString(filters);
|
|
20
|
-
return this.client(`/subscription/template${queryString}`, { method: "GET", ...options });
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Create a new subscription template with the provided template data
|
|
25
|
-
* @async
|
|
26
|
-
* @roles signalhouse
|
|
27
|
-
* @param {Object} params - The parameters for creating a subscription template
|
|
28
|
-
* @param {Object} params.templateData - The data for the new subscription template, including required fields such as templateName and monthlyFee
|
|
29
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
30
|
-
* @throws {Error} Throws an error if the templateData parameter is missing or if required fields within templateData are missing
|
|
31
|
-
* @returns {Promise<Object>} - The created subscription template object returned from the server
|
|
32
|
-
*/
|
|
33
|
-
createTemplate: async ({ templateData, options = {} }) => {
|
|
34
|
-
this.client._require({ templateData: templateData });
|
|
35
|
-
return this.client(`/subscription/template`, { method: "POST", body: templateData, ...options });
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Update an existing subscription template with the provided template data
|
|
40
|
-
* @async
|
|
41
|
-
* @roles signalhouse
|
|
42
|
-
* @param {Object} params - The parameters for updating a subscription template
|
|
43
|
-
* @param {string} params.templateId - The ID of the subscription template to update
|
|
44
|
-
* @param {Object} params.templateData - The data for the subscription template, including fields such as templateName and monthlyFee
|
|
45
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
46
|
-
* @throws {Error} Throws an error if the templateId or templateData parameter is missing
|
|
47
|
-
* @returns {Promise<Object>} - The updated subscription template object returned from the server
|
|
48
|
-
*/
|
|
49
|
-
updateTemplate: async ({ templateId, templateData, options = {} }) => {
|
|
50
|
-
this.client._require({ templateId, templateData });
|
|
51
|
-
const safeTemplateId = encodeURIComponent(templateId);
|
|
52
|
-
return this.client(`/subscription/template/${safeTemplateId}`, { method: "PUT", body: templateData, ...options });
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Delete an existing subscription template
|
|
57
|
-
* @async
|
|
58
|
-
* @roles signalhouse
|
|
59
|
-
* @param {Object} params - The parameters for deleting a subscription template
|
|
60
|
-
* @param {string} params.templateId - The ID of the subscription template to delete
|
|
61
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
62
|
-
* @throws {Error} Throws an error if the templateId parameter is missing
|
|
63
|
-
* @returns {Promise<Object>} - The deleted subscription template object returned from the server
|
|
64
|
-
*/
|
|
65
|
-
deleteTemplate: async ({ templateId, options = {} }) => {
|
|
66
|
-
this.client._require({ templateId });
|
|
67
|
-
const safeTemplateId = encodeURIComponent(templateId);
|
|
68
|
-
return this.client(`/subscription/template/${safeTemplateId}`, { method: "DELETE", ...options });
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Create a custom subscription for a group with the provided subscription data
|
|
73
|
-
* @async
|
|
74
|
-
* @roles signalhouse
|
|
75
|
-
* @param {Object} params - The parameters for creating a custom subscription
|
|
76
|
-
* @param {string} params.groupId - The ID of the group to create the custom subscription for
|
|
77
|
-
* @param {Object} params.subscriptionData - The data for the custom subscription, including required fields such as subscriptionName and monthlyFee
|
|
78
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
79
|
-
* @throws {Error} Throws an error if the groupId or subscriptionData parameter is missing or if required fields within subscriptionData are missing
|
|
80
|
-
* @returns {Promise<Object>} - The created custom subscription object returned from the server
|
|
81
|
-
*/
|
|
82
|
-
createCustomSubscription: async ({ groupId, subscriptionData, options = {} }) => {
|
|
83
|
-
this.client._require({ groupId, subscriptionData });
|
|
84
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
85
|
-
return this.client(`/subscription/user/custom/${safeGroupId}`, { method: "POST", body: subscriptionData, ...options });
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get a list of subscription history for a group, with optional filters
|
|
93
|
-
* @async
|
|
94
|
-
* @roles api, admin, developer, billing, user
|
|
95
|
-
* @param {Object} params - The parameters for getting subscription history
|
|
96
|
-
* @param {string} params.groupId - The ID of the group to get subscription history for
|
|
97
|
-
* @param {boolean} [params.onlyActive] - Whether to only include active subscriptions
|
|
98
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
99
|
-
* @returns {Promise<Object>} - The subscription history returned from the server
|
|
100
|
-
*/
|
|
101
|
-
async getSubscriptions({ groupId, onlyActive, options = {} }) {
|
|
102
|
-
const filters = { groupId, onlyActive };
|
|
103
|
-
const queryString = this.client._getQueryString(filters);
|
|
104
|
-
return this.client(`/subscription/user${queryString}`, { method: "GET", ...options });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Subscribe a group to a template
|
|
109
|
-
* @async
|
|
110
|
-
* @roles api, admin, developer, billing, user
|
|
111
|
-
* @param {Object} params - The parameters for subscribing a group to a template
|
|
112
|
-
* @param {string} params.groupId - The ID of the group to subscribe
|
|
113
|
-
* @param {string} params.templateId - The ID of the template to subscribe the group to
|
|
114
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
115
|
-
* @throws {Error} Throws an error if the groupId or templateId parameter is missing
|
|
116
|
-
* @returns {Promise<Object>} - The subscription object returned from the server
|
|
117
|
-
*/
|
|
118
|
-
async subscribe({ groupId, templateId, options = {} }) {
|
|
119
|
-
this.client._require({ groupId, templateId });
|
|
120
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
121
|
-
const safeTemplateId = encodeURIComponent(templateId);
|
|
122
|
-
return this.client(`/subscription/user/subscribe/${safeGroupId}/${safeTemplateId}`, { method: "POST", body: {}, ...options });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Unsubscribe a group from a template
|
|
127
|
-
* @async
|
|
128
|
-
* @roles api, admin, developer, billing, user
|
|
129
|
-
* @param {Object} params - The parameters for unsubscribing a group from a template
|
|
130
|
-
* @param {string} params.groupId - The ID of the group to unsubscribe
|
|
131
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
132
|
-
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
133
|
-
* @returns {Promise<Object>} - The subscription object returned from the server
|
|
134
|
-
*/
|
|
135
|
-
async unsubscribe({ groupId, options = {} }) {
|
|
136
|
-
this.client._require({ groupId });
|
|
137
|
-
const safeGroupId = encodeURIComponent(groupId);
|
|
138
|
-
return this.client(`/subscription/user/cancel/${safeGroupId}`, { method: "POST", ...options });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
1
|
+
export class Subscriptions {
|
|
2
|
+
constructor(client, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.enableAdmin = enableAdmin;
|
|
5
|
+
|
|
6
|
+
if (enableAdmin) {
|
|
7
|
+
this.admin = {
|
|
8
|
+
/**
|
|
9
|
+
* Get subscription templates with optional filtering by template ID
|
|
10
|
+
* @async
|
|
11
|
+
* @roles signalhouse
|
|
12
|
+
* @param {Object} params - The parameters for getting subscription templates
|
|
13
|
+
* @param {string} [params.templateId] - The ID of a specific template to retrieve (optional)
|
|
14
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
15
|
+
* @returns {Promise<Object>} - The subscription templates returned from the server
|
|
16
|
+
*/
|
|
17
|
+
getTemplates: async ({ templateId, options = {} }) => {
|
|
18
|
+
const filters = { templateId };
|
|
19
|
+
const queryString = this.client._getQueryString(filters);
|
|
20
|
+
return this.client(`/subscription/template${queryString}`, { method: "GET", ...options });
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a new subscription template with the provided template data
|
|
25
|
+
* @async
|
|
26
|
+
* @roles signalhouse
|
|
27
|
+
* @param {Object} params - The parameters for creating a subscription template
|
|
28
|
+
* @param {Object} params.templateData - The data for the new subscription template, including required fields such as templateName and monthlyFee
|
|
29
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
30
|
+
* @throws {Error} Throws an error if the templateData parameter is missing or if required fields within templateData are missing
|
|
31
|
+
* @returns {Promise<Object>} - The created subscription template object returned from the server
|
|
32
|
+
*/
|
|
33
|
+
createTemplate: async ({ templateData, options = {} }) => {
|
|
34
|
+
this.client._require({ templateData: templateData });
|
|
35
|
+
return this.client(`/subscription/template`, { method: "POST", body: templateData, ...options });
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Update an existing subscription template with the provided template data
|
|
40
|
+
* @async
|
|
41
|
+
* @roles signalhouse
|
|
42
|
+
* @param {Object} params - The parameters for updating a subscription template
|
|
43
|
+
* @param {string} params.templateId - The ID of the subscription template to update
|
|
44
|
+
* @param {Object} params.templateData - The data for the subscription template, including fields such as templateName and monthlyFee
|
|
45
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
46
|
+
* @throws {Error} Throws an error if the templateId or templateData parameter is missing
|
|
47
|
+
* @returns {Promise<Object>} - The updated subscription template object returned from the server
|
|
48
|
+
*/
|
|
49
|
+
updateTemplate: async ({ templateId, templateData, options = {} }) => {
|
|
50
|
+
this.client._require({ templateId, templateData });
|
|
51
|
+
const safeTemplateId = encodeURIComponent(templateId);
|
|
52
|
+
return this.client(`/subscription/template/${safeTemplateId}`, { method: "PUT", body: templateData, ...options });
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Delete an existing subscription template
|
|
57
|
+
* @async
|
|
58
|
+
* @roles signalhouse
|
|
59
|
+
* @param {Object} params - The parameters for deleting a subscription template
|
|
60
|
+
* @param {string} params.templateId - The ID of the subscription template to delete
|
|
61
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
62
|
+
* @throws {Error} Throws an error if the templateId parameter is missing
|
|
63
|
+
* @returns {Promise<Object>} - The deleted subscription template object returned from the server
|
|
64
|
+
*/
|
|
65
|
+
deleteTemplate: async ({ templateId, options = {} }) => {
|
|
66
|
+
this.client._require({ templateId });
|
|
67
|
+
const safeTemplateId = encodeURIComponent(templateId);
|
|
68
|
+
return this.client(`/subscription/template/${safeTemplateId}`, { method: "DELETE", ...options });
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create a custom subscription for a group with the provided subscription data
|
|
73
|
+
* @async
|
|
74
|
+
* @roles signalhouse
|
|
75
|
+
* @param {Object} params - The parameters for creating a custom subscription
|
|
76
|
+
* @param {string} params.groupId - The ID of the group to create the custom subscription for
|
|
77
|
+
* @param {Object} params.subscriptionData - The data for the custom subscription, including required fields such as subscriptionName and monthlyFee
|
|
78
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
79
|
+
* @throws {Error} Throws an error if the groupId or subscriptionData parameter is missing or if required fields within subscriptionData are missing
|
|
80
|
+
* @returns {Promise<Object>} - The created custom subscription object returned from the server
|
|
81
|
+
*/
|
|
82
|
+
createCustomSubscription: async ({ groupId, subscriptionData, options = {} }) => {
|
|
83
|
+
this.client._require({ groupId, subscriptionData });
|
|
84
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
85
|
+
return this.client(`/subscription/user/custom/${safeGroupId}`, { method: "POST", body: subscriptionData, ...options });
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get a list of subscription history for a group, with optional filters
|
|
93
|
+
* @async
|
|
94
|
+
* @roles api, admin, developer, billing, user
|
|
95
|
+
* @param {Object} params - The parameters for getting subscription history
|
|
96
|
+
* @param {string} params.groupId - The ID of the group to get subscription history for
|
|
97
|
+
* @param {boolean} [params.onlyActive] - Whether to only include active subscriptions
|
|
98
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
99
|
+
* @returns {Promise<Object>} - The subscription history returned from the server
|
|
100
|
+
*/
|
|
101
|
+
async getSubscriptions({ groupId, onlyActive, options = {} }) {
|
|
102
|
+
const filters = { groupId, onlyActive };
|
|
103
|
+
const queryString = this.client._getQueryString(filters);
|
|
104
|
+
return this.client(`/subscription/user${queryString}`, { method: "GET", ...options });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe a group to a template
|
|
109
|
+
* @async
|
|
110
|
+
* @roles api, admin, developer, billing, user
|
|
111
|
+
* @param {Object} params - The parameters for subscribing a group to a template
|
|
112
|
+
* @param {string} params.groupId - The ID of the group to subscribe
|
|
113
|
+
* @param {string} params.templateId - The ID of the template to subscribe the group to
|
|
114
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
115
|
+
* @throws {Error} Throws an error if the groupId or templateId parameter is missing
|
|
116
|
+
* @returns {Promise<Object>} - The subscription object returned from the server
|
|
117
|
+
*/
|
|
118
|
+
async subscribe({ groupId, templateId, options = {} }) {
|
|
119
|
+
this.client._require({ groupId, templateId });
|
|
120
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
121
|
+
const safeTemplateId = encodeURIComponent(templateId);
|
|
122
|
+
return this.client(`/subscription/user/subscribe/${safeGroupId}/${safeTemplateId}`, { method: "POST", body: {}, ...options });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Unsubscribe a group from a template
|
|
127
|
+
* @async
|
|
128
|
+
* @roles api, admin, developer, billing, user
|
|
129
|
+
* @param {Object} params - The parameters for unsubscribing a group from a template
|
|
130
|
+
* @param {string} params.groupId - The ID of the group to unsubscribe
|
|
131
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
132
|
+
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
133
|
+
* @returns {Promise<Object>} - The subscription object returned from the server
|
|
134
|
+
*/
|
|
135
|
+
async unsubscribe({ groupId, options = {} }) {
|
|
136
|
+
this.client._require({ groupId });
|
|
137
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
138
|
+
return this.client(`/subscription/user/cancel/${safeGroupId}`, { method: "POST", ...options });
|
|
139
|
+
}
|
|
140
|
+
}
|