@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
|
@@ -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
|
+
}
|
package/src/domains/Webhooks.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
export class Webhooks {
|
|
2
|
-
constructor(client, enableAdmin) {
|
|
3
|
-
this.client = client;
|
|
4
|
-
this.enableAdmin = enableAdmin;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get a list of webhooks with optional filters
|
|
9
|
-
* @async
|
|
10
|
-
* @roles api, admin, developer
|
|
11
|
-
* @param {Object} params - The parameters for getting webhooks
|
|
12
|
-
* @param {string} [params.id] - Filter by webhook ID
|
|
13
|
-
* @param {string} [params.groupId] - Filter by associated group ID
|
|
14
|
-
* @param {string} [params.endpointType] - Filter by endpoint type (Global, Number)
|
|
15
|
-
* @param {string} [params.phoneNumber] - Filter by associated phone number (for SMS webhooks)
|
|
16
|
-
* @param {number} [params.page] - The page number for pagination
|
|
17
|
-
* @param {number} [params.limit] - The number of items per page for pagination
|
|
18
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
19
|
-
* @returns {Promise<Array>} The response from the server
|
|
20
|
-
*/
|
|
21
|
-
async getWebhooks({ id, groupId, endpointType, phoneNumber, page, limit, options = {} }) {
|
|
22
|
-
const filters = { id, groupId, endpointType, phoneNumber, page, limit };
|
|
23
|
-
const queryString = this.client._getQueryString(filters);
|
|
24
|
-
return this.client(`/webhook${queryString}`, { method: "GET", ...options });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Create a new webhook with the specified data
|
|
29
|
-
* @async
|
|
30
|
-
* @roles api, admin, developer
|
|
31
|
-
* @param {Object} params - The parameters for creating a webhook
|
|
32
|
-
* @param {Object} params.webhookData - The data for the new webhook
|
|
33
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
34
|
-
* @throws {Error} Throws an error if the webhookData parameter is missing or if required fields in webhookData are missing
|
|
35
|
-
* @returns {Promise<Object>} The response from the server
|
|
36
|
-
*/
|
|
37
|
-
async createWebhook({ webhookData, options = {} }) {
|
|
38
|
-
this.client._require({ webhookData: webhookData });
|
|
39
|
-
return this.client(`/webhook`, { method: "POST", body: webhookData, ...options });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Update an existing webhook with the specified data
|
|
44
|
-
* @async
|
|
45
|
-
* @roles api, admin, developer
|
|
46
|
-
* @param {Object} params - The parameters for updating a webhook
|
|
47
|
-
* @param {string} params.id - The ID of the webhook to update
|
|
48
|
-
* @param {Object} params.updateData - The data for the webhook to be updated, including fields such as endpoint URL and event types
|
|
49
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
50
|
-
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
51
|
-
* @returns {Promise<Object>} The response from the server
|
|
52
|
-
*/
|
|
53
|
-
async updateWebhook({ id, updateData, options = {} }) {
|
|
54
|
-
this.client._require({ id, updateData });
|
|
55
|
-
const safeId = encodeURIComponent(id);
|
|
56
|
-
return this.client(`/webhook/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Delete a webhook by its ID (mark as inactive)
|
|
61
|
-
* @async
|
|
62
|
-
* @roles api, admin, developer
|
|
63
|
-
* @param {Object} params - The parameters for deleting a webhook
|
|
64
|
-
* @param {string} params.id - The ID of the webhook to delete
|
|
65
|
-
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
66
|
-
* @throws {Error} Throws an error if the id parameter is missing
|
|
67
|
-
* @returns {Promise<Object>} The response from the server
|
|
68
|
-
*/
|
|
69
|
-
async deleteWebhook({ id, options = {} }) {
|
|
70
|
-
this.client._require({ id });
|
|
71
|
-
const safeId = encodeURIComponent(id);
|
|
72
|
-
return this.client(`/webhook/${safeId}`, { method: "DELETE", ...options });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
export class Webhooks {
|
|
2
|
+
constructor(client, enableAdmin) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.enableAdmin = enableAdmin;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get a list of webhooks with optional filters
|
|
9
|
+
* @async
|
|
10
|
+
* @roles api, admin, developer
|
|
11
|
+
* @param {Object} params - The parameters for getting webhooks
|
|
12
|
+
* @param {string} [params.id] - Filter by webhook ID
|
|
13
|
+
* @param {string} [params.groupId] - Filter by associated group ID
|
|
14
|
+
* @param {string} [params.endpointType] - Filter by endpoint type (Global, Number)
|
|
15
|
+
* @param {string} [params.phoneNumber] - Filter by associated phone number (for SMS webhooks)
|
|
16
|
+
* @param {number} [params.page] - The page number for pagination
|
|
17
|
+
* @param {number} [params.limit] - The number of items per page for pagination
|
|
18
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
19
|
+
* @returns {Promise<Array>} The response from the server
|
|
20
|
+
*/
|
|
21
|
+
async getWebhooks({ id, groupId, endpointType, phoneNumber, page, limit, options = {} }) {
|
|
22
|
+
const filters = { id, groupId, endpointType, phoneNumber, page, limit };
|
|
23
|
+
const queryString = this.client._getQueryString(filters);
|
|
24
|
+
return this.client(`/webhook${queryString}`, { method: "GET", ...options });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a new webhook with the specified data
|
|
29
|
+
* @async
|
|
30
|
+
* @roles api, admin, developer
|
|
31
|
+
* @param {Object} params - The parameters for creating a webhook
|
|
32
|
+
* @param {Object} params.webhookData - The data for the new webhook
|
|
33
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
34
|
+
* @throws {Error} Throws an error if the webhookData parameter is missing or if required fields in webhookData are missing
|
|
35
|
+
* @returns {Promise<Object>} The response from the server
|
|
36
|
+
*/
|
|
37
|
+
async createWebhook({ webhookData, options = {} }) {
|
|
38
|
+
this.client._require({ webhookData: webhookData });
|
|
39
|
+
return this.client(`/webhook`, { method: "POST", body: webhookData, ...options });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Update an existing webhook with the specified data
|
|
44
|
+
* @async
|
|
45
|
+
* @roles api, admin, developer
|
|
46
|
+
* @param {Object} params - The parameters for updating a webhook
|
|
47
|
+
* @param {string} params.id - The ID of the webhook to update
|
|
48
|
+
* @param {Object} params.updateData - The data for the webhook to be updated, including fields such as endpoint URL and event types
|
|
49
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
50
|
+
* @throws {Error} Throws an error if the id or updateData parameter is missing
|
|
51
|
+
* @returns {Promise<Object>} The response from the server
|
|
52
|
+
*/
|
|
53
|
+
async updateWebhook({ id, updateData, options = {} }) {
|
|
54
|
+
this.client._require({ id, updateData });
|
|
55
|
+
const safeId = encodeURIComponent(id);
|
|
56
|
+
return this.client(`/webhook/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Delete a webhook by its ID (mark as inactive)
|
|
61
|
+
* @async
|
|
62
|
+
* @roles api, admin, developer
|
|
63
|
+
* @param {Object} params - The parameters for deleting a webhook
|
|
64
|
+
* @param {string} params.id - The ID of the webhook to delete
|
|
65
|
+
* @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
|
|
66
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
67
|
+
* @returns {Promise<Object>} The response from the server
|
|
68
|
+
*/
|
|
69
|
+
async deleteWebhook({ id, options = {} }) {
|
|
70
|
+
this.client._require({ id });
|
|
71
|
+
const safeId = encodeURIComponent(id);
|
|
72
|
+
return this.client(`/webhook/${safeId}`, { method: "DELETE", ...options });
|
|
73
|
+
}
|
|
74
|
+
}
|