@signalhousellc/sdk 1.0.49 → 1.0.50

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 CHANGED
@@ -1,38 +1,38 @@
1
- # @signalhouse/sdk
2
-
3
- A lightweight Node.js SDK for the Signal House platform.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @signalhouse/sdk
9
- ```
10
-
11
- Quick Start
12
-
13
- ```bash
14
- import { SignalHouseSDK } from '@signalhouse/sdk';
15
-
16
- const sdk = new SignalHouseSDK({
17
- apiKey: 'your-api-key',
18
- baseUrl: 'api url'
19
- });
20
-
21
- const token = await sdk.auth.login({
22
- email: 'youremail',
23
- password: 'yourpassword'
24
- });
25
-
26
- console.log(token);
27
- ```
28
-
29
- Features
30
- Full support for Signal House API v2
31
- Integrated Axios with standardized returns
32
- Lightweight and tree-shakeable
33
-
34
- Documentation
35
- For full API reference and advanced usage, visit https://api.signalhouse.io
36
-
37
- License
38
- ISC © Signal House
1
+ # @signalhouse/sdk
2
+
3
+ A lightweight Node.js SDK for the Signal House platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @signalhouse/sdk
9
+ ```
10
+
11
+ Quick Start
12
+
13
+ ```bash
14
+ import { SignalHouseSDK } from '@signalhouse/sdk';
15
+
16
+ const sdk = new SignalHouseSDK({
17
+ apiKey: 'your-api-key',
18
+ baseUrl: 'api url'
19
+ });
20
+
21
+ const token = await sdk.auth.login({
22
+ email: 'youremail',
23
+ password: 'yourpassword'
24
+ });
25
+
26
+ console.log(token);
27
+ ```
28
+
29
+ Features
30
+ Full support for Signal House API v2
31
+ Integrated Axios with standardized returns
32
+ Lightweight and tree-shakeable
33
+
34
+ Documentation
35
+ For full API reference and advanced usage, visit https://api.signalhouse.io
36
+
37
+ License
38
+ ISC © Signal House
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalhousellc/sdk",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Signal House SDK for use with the Signal House platform",
5
5
  "type": "module",
6
6
  "main": "src/SignalHouseSDK.js",
@@ -1,54 +1,66 @@
1
- export class Auth {
2
- constructor(client, enableAdmin) {
3
- this.client = client;
4
- this.enableAdmin = enableAdmin;
5
- }
6
-
7
- /**
8
- * Login with email and password
9
- * @async
10
- * @roles public
11
- * @param {Object} params
12
- * @param {string} params.email - The user's email address
13
- * @param {string} params.password - The user's password
14
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
15
- * @returns {Promise<Object>} The response from the server
16
- */
17
- async login({ email, password, options = {} }) {
18
- return this.client(`/auth`, { method: "POST", body: { email, password }, ...options });
19
- }
20
-
21
- /**
22
- * Reset a user's password
23
- * @async
24
- * @roles api, admin, self
25
- * @param {Object} params
26
- * @param {string} params.userId - The id of the user
27
- * @param {string} params.newPassword - The new password to set for the user
28
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
- * @returns {Promise<Object>} The response from the server
30
- */
31
- async resetPassword({ userId, newPassword, options = {} }) {
32
- this.client._require({ userId, newPassword });
33
- const safeUserId = encodeURIComponent(userId);
34
- return this.client(`/auth/resetpassword/${safeUserId}`, { method: "PUT", body: { newPassword }, ...options });
35
- }
36
-
37
- /**
38
- * Get token login history for a group or user
39
- * @async
40
- * @roles signalhouse_admin, signalhouse_api, signalhouse_user, admin, api (groupId query); self (userId query)
41
- * @param {Object} params
42
- * @param {string} [params.groupId] - Returns history for all users in the group (one of groupId/userId required)
43
- * @param {string} [params.userId] - Returns history for a specific user (one of groupId/userId required)
44
- * @param {number} [params.page] - Page number (min 1, default 1)
45
- * @param {number} [params.limit] - Results per page (min 1, max 100, default 20)
46
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
- * @returns {Promise<Object>} The response from the server
48
- */
49
- async getAuthHistory({ groupId, userId, page, limit, options = {} }) {
50
- this.client._require({ "groupId or userId": groupId ?? userId });
51
- const queryString = this.client._getQueryString({ groupId, userId, page, limit });
52
- return this.client(`/auth/history${queryString}`, { method: "GET", ...options });
53
- }
54
- }
1
+ export class Auth {
2
+ constructor(client, enableAdmin) {
3
+ this.client = client;
4
+ this.enableAdmin = enableAdmin;
5
+ }
6
+
7
+ /**
8
+ * Login with email and password
9
+ * @async
10
+ * @roles public
11
+ * @param {Object} params
12
+ * @param {string} params.email - The user's email address
13
+ * @param {string} params.password - The user's password
14
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
15
+ * @returns {Promise<Object>} The response from the server
16
+ */
17
+ async login({ email, password, options = {} }) {
18
+ return this.client(`/auth`, { method: "POST", body: { email, password }, ...options });
19
+ }
20
+
21
+ /**
22
+ * Reset a user's password
23
+ * @async
24
+ * @roles api, admin, self
25
+ * @param {Object} params
26
+ * @param {string} params.userId - The id of the user
27
+ * @param {string} params.newPassword - The new password to set for the user
28
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
+ * @returns {Promise<Object>} The response from the server
30
+ */
31
+ async resetPassword({ userId, newPassword, options = {} }) {
32
+ this.client._require({ userId, newPassword });
33
+ const safeUserId = encodeURIComponent(userId);
34
+ return this.client(`/auth/resetpassword/${safeUserId}`, { method: "PUT", body: { newPassword }, ...options });
35
+ }
36
+
37
+ /**
38
+ * Get token login history for a group or user
39
+ * @async
40
+ * @roles signalhouse_admin, signalhouse_api, signalhouse_user, admin, api (groupId query); self (userId query)
41
+ * @param {Object} params
42
+ * @param {string} [params.groupId] - Returns history for all users in the group (one of groupId/userId required)
43
+ * @param {string} [params.userId] - Returns history for a specific user (one of groupId/userId required)
44
+ * @param {number} [params.page] - Page number (min 1, default 1)
45
+ * @param {number} [params.limit] - Results per page (min 1, max 100, default 20)
46
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
47
+ * @returns {Promise<Object>} The response from the server
48
+ */
49
+ async getAuthHistory({ groupId, userId, page, limit, options = {} }) {
50
+ this.client._require({ "groupId or userId": groupId ?? userId });
51
+ const queryString = this.client._getQueryString({ groupId, userId, page, limit });
52
+ return this.client(`/auth/history${queryString}`, { method: "GET", ...options });
53
+ }
54
+
55
+ /**
56
+ * Log out all other users in the caller's active group
57
+ * @async
58
+ * @roles admin
59
+ * @param {Object} [params]
60
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
61
+ * @returns {Promise<Object>} The response containing loggedOutCount
62
+ */
63
+ async logoutAll({ options = {} } = {}) {
64
+ return this.client(`/auth/logout-all`, { method: "POST", ...options });
65
+ }
66
+ }
@@ -1,132 +1,147 @@
1
- /**
2
- * @typedef {Object} CreateLandingData
3
- * @property {string} brandId - The ID of the brand to associate with the landing page
4
- * @property {string} description - A description of the landing page
5
- * @property {string} primaryBackgroundColor - The primary background color for the landing page (e.g., "#FFFFFF")
6
- * @property {string} secondaryBackgroundColor - The secondary background color for the landing page (e.g., "#F0F0F0")
7
- * @property {string} primaryTextColor - The primary text color for the landing page (e.g., "#000000")
8
- * @property {string} secondaryTextColor - The secondary text color for the landing page (e.g., "#333333")
9
- * @property {Buffer} logo - A logo image file for the landing page, provided as a Buffer
10
- */
11
-
12
- /**
13
- * @typedef {Object} UpdateLandingData
14
- * @property {string} [description] - A description of the landing page
15
- * @property {string} [primaryBackgroundColor] - The primary background color for the landing page (e.g., "#FFFFFF")
16
- * @property {string} [secondaryBackgroundColor] - The secondary background color for the landing page (e.g., "#F0F0F0")
17
- * @property {string} [primaryTextColor] - The primary text color for the landing page (e.g., "#000000")
18
- * @property {string} [secondaryTextColor] - The secondary text color for the landing page (e.g., "#333333")
19
- * @property {Buffer} [logo] - A logo image file for the landing page, provided as a Buffer
20
- */
21
-
22
- export class Landings {
23
- constructor(client, multipartClient, enableAdmin) {
24
- this.client = client;
25
- this.multipartClient = multipartClient;
26
- this.enableAdmin = enableAdmin;
27
- }
28
-
29
- /**
30
- * Get details of a landing page by its ID
31
- * @async
32
- * @roles api, admin, developer, billing, user
33
- * @param {Object} params - The parameters for getting a landing page
34
- * @param {string} params.landingId - The ID of the landing page to retrieve
35
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
- * @throws {Error} Throws an error if the landingId parameter is missing
37
- * @returns {Promise<Object>} - The landing page object returned from the server
38
- */
39
- async getLandings({ landingId, options = {} }) {
40
- this.client._require({ landingId });
41
- const safeLandingId = encodeURIComponent(landingId);
42
- return this.client(`/landing/${safeLandingId}`, { method: "GET", ...options });
43
- }
44
-
45
- /**
46
- * Create a new landing page with the specified landing data and logo file
47
- * @async
48
- * @roles api, admin, developer, billing, user
49
- * @param {Object} params - The parameters for creating a new landing page (see CreateLandingData typedef for details)
50
- * @param {CreateLandingData} params.landingData - The data for the new landing page, including required fields such as brandId and description
51
- * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
52
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
53
- * @returns {Promise<Object>} - The newly created landing page object returned from the server
54
- */
55
- async createLanding({ landingData, file, options = {} }) {
56
- const formData = new FormData();
57
-
58
- if (file) {
59
- formData.append("file", file);
60
- }
61
-
62
- Object.entries(landingData).forEach(([key, value]) => {
63
- if (value !== undefined) {
64
- formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
65
- }
66
- });
67
-
68
- return this.multipartClient(`/landing`, { method: "POST", body: formData, ...options });
69
- }
70
-
71
- /**
72
- * Update an existing landing page with the specified landing data and logo file
73
- * @async
74
- * @roles api, admin, developer, billing, user
75
- * @param {Object} params - The parameters for updating a landing page (see UpdateLandingData typedef for details)
76
- * @param {string} params.landingId - The ID of the landing page to update
77
- * @param {UpdateLandingData} params.landingData - The data for the landing page, including required fields such as brandId and description
78
- * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
79
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
80
- * @throws {Error} Throws an error if the landingId parameter is missing
81
- * @returns {Promise<Object>} - The updated landing page object returned from the server
82
- */
83
- async updateLanding({ landingId, landingData, file, options = {} }) {
84
- this.client._require({ landingId });
85
- const safeLandingId = encodeURIComponent(landingId);
86
- const formData = new FormData();
87
-
88
- if (file) {
89
- formData.append("file", file);
90
- }
91
-
92
- Object.entries(landingData).forEach(([key, value]) => {
93
- if (value !== undefined) {
94
- formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
95
- }
96
- });
97
-
98
- return this.multipartClient(`/landing/${safeLandingId}`, { method: "PUT", body: formData, ...options });
99
- }
100
-
101
- /**
102
- * Delete a landing page by its ID
103
- * @async
104
- * @roles api, admin, developer, billing, user
105
- * @param {Object} params - The parameters for deleting a landing page
106
- * @param {string} params.landingId - The ID of the landing page to delete
107
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
108
- * @throws {Error} Throws an error if the landingId parameter is missing
109
- * @returns {Promise<Object>} - The response from the server after deleting the landing page
110
- */
111
- /**
112
- * Get a landing page by its associated brand ID
113
- * @async
114
- * @roles api, admin, developer, billing, user
115
- * @param {Object} params - The parameters for getting a landing page by brand
116
- * @param {string} params.brandId - The brand ID to look up the landing page for
117
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
118
- * @throws {Error} Throws an error if the brandId parameter is missing
119
- * @returns {Promise<Object>} - The landing page object returned from the server
120
- */
121
- async getLandingByBrandId({ brandId, options = {} }) {
122
- this.client._require({ brandId });
123
- const safeBrandId = encodeURIComponent(brandId);
124
- return this.client(`/landing/brand/${safeBrandId}`, { method: "GET", ...options });
125
- }
126
-
127
- async deleteLanding({ landingId, options = {} }) {
128
- this.client._require({ landingId });
129
- const safeLandingId = encodeURIComponent(landingId);
130
- return this.client(`/landing/${safeLandingId}`, { method: "DELETE", ...options });
131
- }
132
- }
1
+ /**
2
+ * @typedef {Object} CreateLandingData
3
+ * @property {string} brandId - The ID of the brand to associate with the landing page
4
+ * @property {string} description - A description of the landing page
5
+ * @property {string} primaryBackgroundColor - The primary background color for the landing page (e.g., "#FFFFFF")
6
+ * @property {string} secondaryBackgroundColor - The secondary background color for the landing page (e.g., "#F0F0F0")
7
+ * @property {string} primaryTextColor - The primary text color for the landing page (e.g., "#000000")
8
+ * @property {string} secondaryTextColor - The secondary text color for the landing page (e.g., "#333333")
9
+ * @property {Buffer} logo - A logo image file for the landing page, provided as a Buffer
10
+ */
11
+
12
+ /**
13
+ * @typedef {Object} UpdateLandingData
14
+ * @property {string} [description] - A description of the landing page
15
+ * @property {string} [primaryBackgroundColor] - The primary background color for the landing page (e.g., "#FFFFFF")
16
+ * @property {string} [secondaryBackgroundColor] - The secondary background color for the landing page (e.g., "#F0F0F0")
17
+ * @property {string} [primaryTextColor] - The primary text color for the landing page (e.g., "#000000")
18
+ * @property {string} [secondaryTextColor] - The secondary text color for the landing page (e.g., "#333333")
19
+ * @property {Buffer} [logo] - A logo image file for the landing page, provided as a Buffer
20
+ */
21
+
22
+ export class Landings {
23
+ constructor(client, multipartClient, enableAdmin) {
24
+ this.client = client;
25
+ this.multipartClient = multipartClient;
26
+ this.enableAdmin = enableAdmin;
27
+ }
28
+
29
+ /**
30
+ * Get details of a landing page by its ID
31
+ * @async
32
+ * @roles api, admin, developer, billing, user
33
+ * @param {Object} params - The parameters for getting a landing page
34
+ * @param {string} params.landingId - The ID of the landing page to retrieve
35
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
36
+ * @throws {Error} Throws an error if the landingId parameter is missing
37
+ * @returns {Promise<Object>} - The landing page object returned from the server
38
+ */
39
+ async getLandings({ landingId, options = {} }) {
40
+ this.client._require({ landingId });
41
+ const safeLandingId = encodeURIComponent(landingId);
42
+ return this.client(`/landing/${safeLandingId}`, { method: "GET", ...options });
43
+ }
44
+
45
+ /**
46
+ * Get a public (published) landing page by its ID. This endpoint is public and does not require authentication.
47
+ * @async
48
+ * @param {Object} params - The parameters for getting a public landing page
49
+ * @param {string} params.landingId - The ID of the public landing page to retrieve
50
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
51
+ * @throws {Error} Throws an error if the landingId parameter is missing
52
+ * @returns {Promise<Object>} - The public landing page object returned from the server
53
+ */
54
+ async getPublicLanding({ landingId, options = {} }) {
55
+ this.client._require({ landingId });
56
+ const safeLandingId = encodeURIComponent(landingId);
57
+ return this.client(`/landing/public/${safeLandingId}`, { method: "GET", ...options });
58
+ }
59
+
60
+ /**
61
+ * Create a new landing page with the specified landing data and logo file
62
+ * @async
63
+ * @roles api, admin, developer, billing, user
64
+ * @param {Object} params - The parameters for creating a new landing page (see CreateLandingData typedef for details)
65
+ * @param {CreateLandingData} params.landingData - The data for the new landing page, including required fields such as brandId and description
66
+ * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
67
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
68
+ * @returns {Promise<Object>} - The newly created landing page object returned from the server
69
+ */
70
+ async createLanding({ landingData, file, options = {} }) {
71
+ const formData = new FormData();
72
+
73
+ if (file) {
74
+ formData.append("file", file);
75
+ }
76
+
77
+ Object.entries(landingData).forEach(([key, value]) => {
78
+ if (value !== undefined) {
79
+ formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
80
+ }
81
+ });
82
+
83
+ return this.multipartClient(`/landing`, { method: "POST", body: formData, ...options });
84
+ }
85
+
86
+ /**
87
+ * Update an existing landing page with the specified landing data and logo file
88
+ * @async
89
+ * @roles api, admin, developer, billing, user
90
+ * @param {Object} params - The parameters for updating a landing page (see UpdateLandingData typedef for details)
91
+ * @param {string} params.landingId - The ID of the landing page to update
92
+ * @param {UpdateLandingData} params.landingData - The data for the landing page, including required fields such as brandId and description
93
+ * @param {Buffer} params.file - A logo image file for the landing page, provided as a Buffer
94
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
95
+ * @throws {Error} Throws an error if the landingId parameter is missing
96
+ * @returns {Promise<Object>} - The updated landing page object returned from the server
97
+ */
98
+ async updateLanding({ landingId, landingData, file, options = {} }) {
99
+ this.client._require({ landingId });
100
+ const safeLandingId = encodeURIComponent(landingId);
101
+ const formData = new FormData();
102
+
103
+ if (file) {
104
+ formData.append("file", file);
105
+ }
106
+
107
+ Object.entries(landingData).forEach(([key, value]) => {
108
+ if (value !== undefined) {
109
+ formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
110
+ }
111
+ });
112
+
113
+ return this.multipartClient(`/landing/${safeLandingId}`, { method: "PUT", body: formData, ...options });
114
+ }
115
+
116
+ /**
117
+ * Delete a landing page by its ID
118
+ * @async
119
+ * @roles api, admin, developer, billing, user
120
+ * @param {Object} params - The parameters for deleting a landing page
121
+ * @param {string} params.landingId - The ID of the landing page to delete
122
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
123
+ * @throws {Error} Throws an error if the landingId parameter is missing
124
+ * @returns {Promise<Object>} - The response from the server after deleting the landing page
125
+ */
126
+ /**
127
+ * Get a landing page by its associated brand ID
128
+ * @async
129
+ * @roles api, admin, developer, billing, user
130
+ * @param {Object} params - The parameters for getting a landing page by brand
131
+ * @param {string} params.brandId - The brand ID to look up the landing page for
132
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
133
+ * @throws {Error} Throws an error if the brandId parameter is missing
134
+ * @returns {Promise<Object>} - The landing page object returned from the server
135
+ */
136
+ async getLandingByBrandId({ brandId, options = {} }) {
137
+ this.client._require({ brandId });
138
+ const safeBrandId = encodeURIComponent(brandId);
139
+ return this.client(`/landing/brand/${safeBrandId}`, { method: "GET", ...options });
140
+ }
141
+
142
+ async deleteLanding({ landingId, options = {} }) {
143
+ this.client._require({ landingId });
144
+ const safeLandingId = encodeURIComponent(landingId);
145
+ return this.client(`/landing/${safeLandingId}`, { method: "DELETE", ...options });
146
+ }
147
+ }
@@ -56,6 +56,26 @@ export class Messages {
56
56
  return this.client(`/message${queryString}`, { method: "GET", ...options });
57
57
  }
58
58
 
59
+ /**
60
+ * Fetch the latest upstream carrier delivery report for a set of messages by ID (SHGHL-1856).
61
+ * Useful for reconciling messages stuck in a non-terminal state. SMS and MMS messages are looked up
62
+ * against the carrier; other message types are returned with their stored status.
63
+ * @async
64
+ * @roles api, admin, developer, billing, user
65
+ * @param {Object} params - The parameters for fetching delivery reports
66
+ * @param {string[]} params.messageIds - The message IDs to fetch carrier delivery reports for (1-100)
67
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
68
+ * @returns {Promise<Object>} - A promise that resolves to an array of carrier delivery reports
69
+ */
70
+ async getDeliveryReports({ messageIds, options = {} }) {
71
+ this.client._require({ messageIds });
72
+ return this.client(`/message/delivery-report`, {
73
+ method: "POST",
74
+ body: { messageIds },
75
+ ...options,
76
+ });
77
+ }
78
+
59
79
  /**
60
80
  * Get aggregated analytics for messages with optional filters
61
81
  * @async
@@ -261,6 +281,22 @@ export class Messages {
261
281
  });
262
282
  }
263
283
 
284
+ /**
285
+ * Get the details of a P2P batch by its ID
286
+ * @async
287
+ * @roles api, admin, developer, billing, user
288
+ * @param {Object} params - The parameters for getting a P2P batch
289
+ * @param {string} params.batchId - The ID of the P2P batch to retrieve
290
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
291
+ * @throws {Error} Throws an error if the batchId parameter is missing
292
+ * @returns {Promise<Object>} - The P2P batch object returned from the server
293
+ */
294
+ async getP2PBatch({ batchId, options = {} }) {
295
+ this.client._require({ batchId });
296
+ const safeBatchId = encodeURIComponent(batchId);
297
+ return this.client(`/message/p2p/batches/${safeBatchId}`, { method: "GET", ...options });
298
+ }
299
+
264
300
  /**
265
301
  * Send an MMS message to one or more recipient phone numbers, with optional media attachments and status callback
266
302
  * @async
@@ -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
+ }
@@ -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
+ }
@@ -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
+ }