@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.
@@ -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
+ }