@signalhousellc/sdk 1.0.31 → 1.0.33

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,257 +1,280 @@
1
- export class Messages {
2
- constructor(client, multipartClient, enableAdmin) {
3
- this.client = client;
4
- this.multipartClient = multipartClient;
5
- this.enableAdmin = enableAdmin;
6
- }
7
-
8
- /**
9
- * Get a list of messages with optional filters and pagination parameters
10
- * @async
11
- * @roles api, admin, developer, billing, user
12
- * @param {Object} params - The parameters for getting messages
13
- * @param {string} [params.id] - Filter messages by their unique ID
14
- * @param {string} [params.campaignId] - Filter messages by the ID of the associated campaign
15
- * @param {string} [params.brandId] - Filter messages by the ID of the associated brand
16
- * @param {string} [params.subgroupId] - Filter messages by the ID of the associated subgroup
17
- * @param {string} [params.groupId] - Filter messages by the ID of the associated group
18
- * @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED)
19
- * @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
20
- * @param {string} [params.messageType] - Filter messages by their type (SMS, MMS)
21
- * @param {string} [params.carrier] - Filter messages by the carrier used for sending
22
- * @param {string} [params.startDate] - Filter messages by their start date
23
- * @param {string} [params.endDate] - Filter messages by their end date
24
- * @param {string} [params.sortField] - The field to sort the messages by
25
- * @param {string} [params.sortOrder] - The order to sort the messages (asc, desc)
26
- * @param {number} [params.page] - The page number for pagination
27
- * @param {number} [params.limit] - The number of messages per page
28
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
- * @returns {Promise<Object>} - A promise that resolves to the list of messages
30
- */
31
- async getMessages({
32
- id,
33
- campaignId,
34
- brandId,
35
- subgroupId,
36
- groupId,
37
- status,
38
- direction,
39
- messageType,
40
- carrier,
41
- startDate,
42
- endDate,
43
- sortField,
44
- sortOrder,
45
- page,
46
- limit,
47
- options = {},
48
- }) {
49
- const filters = { id, campaignId, brandId, subgroupId, groupId, status, direction, messageType, carrier, startDate, endDate, sortField, sortOrder, page, limit };
50
- const queryString = this.client._getQueryString(filters);
51
- return this.client(`/message${queryString}`, { method: "GET", ...options });
52
- }
53
-
54
- /**
55
- * Get aggregated analytics for messages with optional filters
56
- * @async
57
- * @roles api, admin, developer, billing, user
58
- * @param {Object} params - The parameters for getting analytics
59
- * @param {string} [params.groupId] - Filter analytics by the ID of the associated group
60
- * @param {string} [params.subgroupId] - Filter analytics by the ID of the associated subgroup
61
- * @param {string} [params.brandId] - Filter analytics by the ID of the associated brand
62
- * @param {string} [params.campaignId] - Filter analytics by the ID of the associated campaign
63
- * @param {string} [params.phoneNumber] - Filter analytics by the phone number involved in the messages
64
- * @param {string} [params.carrier] - Filter analytics by the carrier used for sending
65
- * @param {string} [params.startDate] - Filter analytics by the start date of the messages
66
- * @param {string} [params.endDate] - Filter analytics by the end date of the messages
67
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
68
- * @returns {Promise<Object>} - A promise that resolves to the analytics data
69
- */
70
- async getAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
71
- const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
72
- const queryString = this.client._getQueryString(filters);
73
- return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
74
- }
75
-
76
- /**
77
- * Get aggregated DNC (Do Not Contact) opt-out analytics with optional filters
78
- * @async
79
- * @roles api, admin, developer, billing, user
80
- * @param {Object} params - The parameters for getting DNC analytics
81
- * @param {string} [params.groupId] - Filter by the ID of the associated group
82
- * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
83
- * @param {string} [params.brandId] - Filter by the ID of the associated brand
84
- * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
85
- * @param {string} [params.phoneNumber] - Filter by the phone number
86
- * @param {string} [params.carrier] - Filter by the carrier
87
- * @param {string} [params.startDate] - Filter by start date
88
- * @param {string} [params.endDate] - Filter by end date
89
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
90
- * @returns {Promise<Object>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, byCarrier)
91
- */
92
- async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
93
- const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
94
- const queryString = this.client._getQueryString(filters);
95
- return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
96
- }
97
-
98
- /**
99
- * Get paginated Do Not Call records with optional filters
100
- * @async
101
- * @roles api, admin, developer, billing, user
102
- * @param {Object} params - The parameters for getting DNC records
103
- * @param {string} [params.groupId] - Filter by the ID of the associated group
104
- * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
105
- * @param {string} [params.brandId] - Filter by the ID of the associated brand
106
- * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
107
- * @param {string} [params.phoneNumber] - Filter by the phone number
108
- * @param {string} [params.carrier] - Filter by the carrier
109
- * @param {string} [params.startDate] - Filter by start date
110
- * @param {string} [params.endDate] - Filter by end date
111
- * @param {number} [params.page] - Page number for pagination
112
- * @param {number} [params.limit] - Number of records per page
113
- * @param {string} [params.sortField] - Field to sort by
114
- * @param {string} [params.sortOrder] - Sort direction (asc, desc)
115
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
116
- * @returns {Promise<Object>} - A promise that resolves to the paginated DNC records
117
- */
118
- async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, options = {} }) {
119
- const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder };
120
- const queryString = this.client._getQueryString(filters);
121
- return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
122
- }
123
-
124
- /**
125
- * Send an SMS message to one or more recipient phone numbers
126
- * @async
127
- * @roles api, admin, developer, billing, user
128
- * @param {Object} params - The parameters for sending an SMS message
129
- * @param {string} params.senderPhoneNumber - The phone number to send the message from
130
- * @param {string|string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
131
- * @param {string} params.messageBody - The body of the SMS message
132
- * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
133
- * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
134
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
135
- * @returns {Promise<Object>} - A promise that resolves to the response data from the server
136
- */
137
- async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, options = {} }) {
138
- this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
139
- return this.client(`/message/sms`, {
140
- method: "POST",
141
- body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink },
142
- ...options,
143
- });
144
- }
145
-
146
- /**
147
- * Send an MMS message to one or more recipient phone numbers, with optional media attachments and status callback
148
- * @async
149
- * @roles api, admin, developer, billing, user
150
- * @param {Object} params - The parameters for sending an MMS message
151
- * @param {string} params.senderPhoneNumber - The phone number to send the message from
152
- * @param {string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
153
- * @param {string} params.messageBody - The body of the MMS message
154
- * @param {string[]} [params.mediaUrls] - The URLs of the media attachments
155
- * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
156
- * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
157
- * @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
158
- * @param {File[]} [params.images] - The images to attach to the MMS message
159
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
160
- * @returns {Promise<Object>} - A promise that resolves to the response data from the server
161
- */
162
- async sendMMS({
163
- senderPhoneNumber,
164
- recipientPhoneNumbers,
165
- messageBody,
166
- mediaUrls,
167
- statusCallbackUrl,
168
- enableShortlink = false,
169
- enableCompression = true,
170
- images,
171
- options = {},
172
- }) {
173
- this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
174
-
175
- const formData = new FormData();
176
-
177
- if (images && images.length > 0) {
178
- images.forEach((image, index) => {
179
- formData.append("images", image);
180
- });
181
- }
182
-
183
- formData.append("senderPhoneNumber", senderPhoneNumber);
184
-
185
- formData.append("recipientPhoneNumber", Array.isArray(recipientPhoneNumbers) ? JSON.stringify(recipientPhoneNumbers) : recipientPhoneNumbers);
186
- formData.append("messageBody", messageBody);
187
-
188
- if (mediaUrls && mediaUrls.length > 0) {
189
- formData.append("mediaUrls", JSON.stringify(mediaUrls));
190
- }
191
-
192
- if (statusCallbackUrl) {
193
- formData.append("statusCallbackUrl", statusCallbackUrl);
194
- }
195
-
196
- formData.append("enableShortlink", enableShortlink);
197
- formData.append("enableCompression", enableCompression);
198
-
199
- return this.multipartClient(`/message/mms`, { method: "POST", body: formData, ...options });
200
- }
201
-
202
- /**
203
- * Send a group MMS message to one or more recipient phone numbers, with optional media attachments and status callback
204
- * @async
205
- * @roles api, admin, developer, billing, user
206
- * @param {Object} params - The parameters for sending an MMS message
207
- * @param {string} params.senderPhoneNumber - The phone number to send the message from
208
- * @param {string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
209
- * @param {string} params.messageBody - The body of the MMS message
210
- * @param {string[]} [params.mediaUrls] - The URLs of the media attachments
211
- * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
212
- * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
213
- * @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
214
- * @param {File[]} [params.images] - The images to attach to the MMS message
215
- * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
216
- * @returns {Promise<Object>} - A promise that resolves to the response data from the server
217
- */
218
- async sendGroupMessage({
219
- senderPhoneNumber,
220
- recipientPhoneNumbers,
221
- messageBody,
222
- mediaUrls,
223
- statusCallbackUrl,
224
- enableShortlink = false,
225
- enableCompression = true,
226
- images,
227
- options = {},
228
- }) {
229
- this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
230
-
231
- const formData = new FormData();
232
-
233
- if (images && images.length > 0) {
234
- images.forEach((image, index) => {
235
- formData.append("images", image);
236
- });
237
- }
238
-
239
- formData.append("senderPhoneNumber", senderPhoneNumber);
240
-
241
- formData.append("recipientPhoneNumber", Array.isArray(recipientPhoneNumbers) ? JSON.stringify(recipientPhoneNumbers) : recipientPhoneNumbers);
242
- formData.append("messageBody", messageBody);
243
-
244
- if (mediaUrls && mediaUrls.length > 0) {
245
- formData.append("mediaUrls", JSON.stringify(mediaUrls));
246
- }
247
-
248
- if (statusCallbackUrl) {
249
- formData.append("statusCallbackUrl", statusCallbackUrl);
250
- }
251
-
252
- formData.append("enableShortlink", enableShortlink);
253
- formData.append("enableCompression", enableCompression);
254
-
255
- return this.multipartClient(`/message/groupMessage`, { method: "POST", body: formData, ...options });
256
- }
257
- }
1
+ export class Messages {
2
+ constructor(client, multipartClient, enableAdmin) {
3
+ this.client = client;
4
+ this.multipartClient = multipartClient;
5
+ this.enableAdmin = enableAdmin;
6
+ }
7
+
8
+ /**
9
+ * Get a list of messages with optional filters and pagination parameters
10
+ * @async
11
+ * @roles api, admin, developer, billing, user
12
+ * @param {Object} params - The parameters for getting messages
13
+ * @param {string} [params.id] - Filter messages by their unique ID
14
+ * @param {string} [params.campaignId] - Filter messages by the ID of the associated campaign
15
+ * @param {string} [params.brandId] - Filter messages by the ID of the associated brand
16
+ * @param {string} [params.subgroupId] - Filter messages by the ID of the associated subgroup
17
+ * @param {string} [params.groupId] - Filter messages by the ID of the associated group
18
+ * @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED)
19
+ * @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
20
+ * @param {string} [params.messageType] - Filter messages by their type (SMS, MMS)
21
+ * @param {string} [params.carrier] - Filter messages by the carrier used for sending
22
+ * @param {string} [params.startDate] - Filter messages by their start date
23
+ * @param {string} [params.endDate] - Filter messages by their end date
24
+ * @param {string} [params.sortField] - The field to sort the messages by
25
+ * @param {string} [params.sortOrder] - The order to sort the messages (asc, desc)
26
+ * @param {number} [params.page] - The page number for pagination
27
+ * @param {number} [params.limit] - The number of messages per page
28
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
29
+ * @returns {Promise<Object>} - A promise that resolves to the list of messages
30
+ */
31
+ async getMessages({
32
+ id,
33
+ campaignId,
34
+ brandId,
35
+ subgroupId,
36
+ groupId,
37
+ phoneNumber,
38
+ status,
39
+ direction,
40
+ messageType,
41
+ carrier,
42
+ startDate,
43
+ endDate,
44
+ sortField,
45
+ sortOrder,
46
+ page,
47
+ limit,
48
+ options = {},
49
+ }) {
50
+ const filters = { id, campaignId, brandId, subgroupId, groupId, phoneNumber, status, direction, messageType, carrier, startDate, endDate, sortField, sortOrder, page, limit };
51
+ const queryString = this.client._getQueryString(filters);
52
+ return this.client(`/message${queryString}`, { method: "GET", ...options });
53
+ }
54
+
55
+ /**
56
+ * Get aggregated analytics for messages with optional filters
57
+ * @async
58
+ * @roles api, admin, developer, billing, user
59
+ * @param {Object} params - The parameters for getting analytics
60
+ * @param {string} [params.groupId] - Filter analytics by the ID of the associated group
61
+ * @param {string} [params.subgroupId] - Filter analytics by the ID of the associated subgroup
62
+ * @param {string} [params.brandId] - Filter analytics by the ID of the associated brand
63
+ * @param {string} [params.campaignId] - Filter analytics by the ID of the associated campaign
64
+ * @param {string} [params.phoneNumber] - Filter analytics by the phone number involved in the messages
65
+ * @param {string} [params.carrier] - Filter analytics by the carrier used for sending
66
+ * @param {string} [params.startDate] - Filter analytics by the start date of the messages
67
+ * @param {string} [params.endDate] - Filter analytics by the end date of the messages
68
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
69
+ * @returns {Promise<Object>} - A promise that resolves to the analytics data
70
+ */
71
+ async getAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
72
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
73
+ const queryString = this.client._getQueryString(filters);
74
+ return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
75
+ }
76
+
77
+ /**
78
+ * Get detailed analytics snapshot records for charting and aggregation
79
+ * @async
80
+ * @roles api, admin, developer, billing, user
81
+ * @param {Object} params - The parameters for getting detailed analytics
82
+ * @param {string} [params.groupId] - Filter analytics by the ID of the associated group
83
+ * @param {string} [params.subgroupId] - Filter analytics by the ID of the associated subgroup
84
+ * @param {string} [params.brandId] - Filter analytics by the ID of the associated brand
85
+ * @param {string} [params.campaignId] - Filter analytics by the ID of the associated campaign
86
+ * @param {string} [params.phoneNumber] - Filter analytics by the phone number involved in the messages
87
+ * @param {string} [params.carrier] - Filter analytics by the carrier used for sending
88
+ * @param {string} [params.startDate] - Filter analytics by the start date of the messages
89
+ * @param {string} [params.endDate] - Filter analytics by the end date of the messages
90
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
91
+ * @returns {Promise<Array>} - A promise that resolves to an array of analytics snapshot records
92
+ */
93
+ async getAnalyticsDetail({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
94
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
95
+ const queryString = this.client._getQueryString(filters);
96
+ return this.client(`/message/analytics/detail${queryString}`, { method: "GET", ...options });
97
+ }
98
+
99
+ /**
100
+ * Get aggregated DNC (Do Not Contact) opt-out analytics with optional filters
101
+ * @async
102
+ * @roles api, admin, developer, billing, user
103
+ * @param {Object} params - The parameters for getting DNC analytics
104
+ * @param {string} [params.groupId] - Filter by the ID of the associated group
105
+ * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
106
+ * @param {string} [params.brandId] - Filter by the ID of the associated brand
107
+ * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
108
+ * @param {string} [params.phoneNumber] - Filter by the phone number
109
+ * @param {string} [params.carrier] - Filter by the carrier
110
+ * @param {string} [params.startDate] - Filter by start date
111
+ * @param {string} [params.endDate] - Filter by end date
112
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
113
+ * @returns {Promise<Object>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, byCarrier)
114
+ */
115
+ async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, options = {} }) {
116
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate };
117
+ const queryString = this.client._getQueryString(filters);
118
+ return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
119
+ }
120
+
121
+ /**
122
+ * Get paginated Do Not Call records with optional filters
123
+ * @async
124
+ * @roles api, admin, developer, billing, user
125
+ * @param {Object} params - The parameters for getting DNC records
126
+ * @param {string} [params.groupId] - Filter by the ID of the associated group
127
+ * @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
128
+ * @param {string} [params.brandId] - Filter by the ID of the associated brand
129
+ * @param {string} [params.campaignId] - Filter by the ID of the associated campaign
130
+ * @param {string} [params.phoneNumber] - Filter by the phone number
131
+ * @param {string} [params.carrier] - Filter by the carrier
132
+ * @param {string} [params.startDate] - Filter by start date
133
+ * @param {string} [params.endDate] - Filter by end date
134
+ * @param {number} [params.page] - Page number for pagination
135
+ * @param {number} [params.limit] - Number of records per page
136
+ * @param {string} [params.sortField] - Field to sort by
137
+ * @param {string} [params.sortOrder] - Sort direction (asc, desc)
138
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
139
+ * @returns {Promise<Object>} - A promise that resolves to the paginated DNC records
140
+ */
141
+ async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, options = {} }) {
142
+ const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder };
143
+ const queryString = this.client._getQueryString(filters);
144
+ return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
145
+ }
146
+
147
+ /**
148
+ * Send an SMS message to one or more recipient phone numbers
149
+ * @async
150
+ * @roles api, admin, developer, billing, user
151
+ * @param {Object} params - The parameters for sending an SMS message
152
+ * @param {string} params.senderPhoneNumber - The phone number to send the message from
153
+ * @param {string|string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
154
+ * @param {string} params.messageBody - The body of the SMS message
155
+ * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
156
+ * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
157
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
158
+ * @returns {Promise<Object>} - A promise that resolves to the response data from the server
159
+ */
160
+ async sendSMS({ senderPhoneNumber, recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink = false, options = {} }) {
161
+ this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
162
+ return this.client(`/message/sms`, {
163
+ method: "POST",
164
+ body: { senderPhoneNumber, recipientPhoneNumber: recipientPhoneNumbers, messageBody, statusCallbackUrl, enableShortlink },
165
+ ...options,
166
+ });
167
+ }
168
+
169
+ /**
170
+ * Send an MMS message to one or more recipient phone numbers, with optional media attachments and status callback
171
+ * @async
172
+ * @roles api, admin, developer, billing, user
173
+ * @param {Object} params - The parameters for sending an MMS message
174
+ * @param {string} params.senderPhoneNumber - The phone number to send the message from
175
+ * @param {string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
176
+ * @param {string} params.messageBody - The body of the MMS message
177
+ * @param {string[]} [params.mediaUrls] - The URLs of the media attachments
178
+ * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
179
+ * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
180
+ * @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
181
+ * @param {File[]} [params.images] - The images to attach to the MMS message
182
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
183
+ * @returns {Promise<Object>} - A promise that resolves to the response data from the server
184
+ */
185
+ async sendMMS({
186
+ senderPhoneNumber,
187
+ recipientPhoneNumbers,
188
+ messageBody,
189
+ mediaUrls,
190
+ statusCallbackUrl,
191
+ enableShortlink = false,
192
+ enableCompression = true,
193
+ images,
194
+ options = {},
195
+ }) {
196
+ this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
197
+
198
+ const formData = new FormData();
199
+
200
+ if (images && images.length > 0) {
201
+ images.forEach((image, index) => {
202
+ formData.append("images", image);
203
+ });
204
+ }
205
+
206
+ formData.append("senderPhoneNumber", senderPhoneNumber);
207
+
208
+ formData.append("recipientPhoneNumber", Array.isArray(recipientPhoneNumbers) ? JSON.stringify(recipientPhoneNumbers) : recipientPhoneNumbers);
209
+ formData.append("messageBody", messageBody);
210
+
211
+ if (mediaUrls && mediaUrls.length > 0) {
212
+ formData.append("mediaUrls", JSON.stringify(mediaUrls));
213
+ }
214
+
215
+ if (statusCallbackUrl) {
216
+ formData.append("statusCallbackUrl", statusCallbackUrl);
217
+ }
218
+
219
+ formData.append("enableShortlink", enableShortlink);
220
+ formData.append("enableCompression", enableCompression);
221
+
222
+ return this.multipartClient(`/message/mms`, { method: "POST", body: formData, ...options });
223
+ }
224
+
225
+ /**
226
+ * Send a group MMS message to one or more recipient phone numbers, with optional media attachments and status callback
227
+ * @async
228
+ * @roles api, admin, developer, billing, user
229
+ * @param {Object} params - The parameters for sending an MMS message
230
+ * @param {string} params.senderPhoneNumber - The phone number to send the message from
231
+ * @param {string[]} params.recipientPhoneNumbers - The phone number(s) to send the message to
232
+ * @param {string} params.messageBody - The body of the MMS message
233
+ * @param {string[]} [params.mediaUrls] - The URLs of the media attachments
234
+ * @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
235
+ * @param {boolean} [params.enableShortlink=false] - Whether to enable shortlink in the message
236
+ * @param {boolean} [params.enableCompression=true] - Whether to enable image compression for the image attachments
237
+ * @param {File[]} [params.images] - The images to attach to the MMS message
238
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
239
+ * @returns {Promise<Object>} - A promise that resolves to the response data from the server
240
+ */
241
+ async sendGroupMessage({
242
+ senderPhoneNumber,
243
+ recipientPhoneNumbers,
244
+ messageBody,
245
+ mediaUrls,
246
+ statusCallbackUrl,
247
+ enableShortlink = false,
248
+ enableCompression = true,
249
+ images,
250
+ options = {},
251
+ }) {
252
+ this.client._require({ senderPhoneNumber, recipientPhoneNumbers, messageBody });
253
+
254
+ const formData = new FormData();
255
+
256
+ if (images && images.length > 0) {
257
+ images.forEach((image, index) => {
258
+ formData.append("images", image);
259
+ });
260
+ }
261
+
262
+ formData.append("senderPhoneNumber", senderPhoneNumber);
263
+
264
+ formData.append("recipientPhoneNumber", Array.isArray(recipientPhoneNumbers) ? JSON.stringify(recipientPhoneNumbers) : recipientPhoneNumbers);
265
+ formData.append("messageBody", messageBody);
266
+
267
+ if (mediaUrls && mediaUrls.length > 0) {
268
+ formData.append("mediaUrls", JSON.stringify(mediaUrls));
269
+ }
270
+
271
+ if (statusCallbackUrl) {
272
+ formData.append("statusCallbackUrl", statusCallbackUrl);
273
+ }
274
+
275
+ formData.append("enableShortlink", enableShortlink);
276
+ formData.append("enableCompression", enableCompression);
277
+
278
+ return this.multipartClient(`/message/groupMessage`, { method: "POST", body: formData, ...options });
279
+ }
280
+ }
@@ -323,4 +323,19 @@ export class Numbers {
323
323
  async lookupLocations({ entries, options = {} }) {
324
324
  return this.client("/number/lookup/location", { method: "POST", body: { entries }, ...options });
325
325
  }
326
+
327
+ /**
328
+ * Migrate a phone number (or all numbers in a campaign/group) from v1 to v2
329
+ * @async
330
+ * @roles api, admin, developer, billing, user, signalhouse_api, signalhouse_admin, signalhouse_user
331
+ * @param {Object} params - The parameters for migration
332
+ * @param {string} [params.phoneNumber] - The phone number to migrate
333
+ * @param {string} [params.campaignId] - Campaign ID to migrate all numbers for
334
+ * @param {string} [params.groupId] - Group ID to migrate all numbers for
335
+ * @param {import('../SignalHouseSDK').RequestOptions} [params.options] - Additional options for the request
336
+ * @returns {Promise<Object>} A promise that resolves to a confirmation with count of queued numbers
337
+ */
338
+ async migratePhoneNumberToV2({ phoneNumber, campaignId, groupId, options = {} }) {
339
+ return this.client(`/number/migrate`, { method: "POST", body: { phoneNumber, campaignId, groupId }, ...options });
340
+ }
326
341
  }