@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.
- package/package.json +1 -1
- package/src/SignalHouseSDK.js +154 -154
- package/src/domains/Billing.js +172 -172
- package/src/domains/Brands.js +236 -236
- package/src/domains/Campaigns.js +210 -210
- package/src/domains/Messages.js +280 -257
- package/src/domains/Numbers.js +15 -0
package/src/domains/Messages.js
CHANGED
|
@@ -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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {string} [params.
|
|
61
|
-
* @param {string} [params.
|
|
62
|
-
* @param {string} [params.
|
|
63
|
-
* @param {string} [params.
|
|
64
|
-
* @param {string} [params.
|
|
65
|
-
* @param {string} [params.
|
|
66
|
-
* @param {string} [params.
|
|
67
|
-
* @param {
|
|
68
|
-
* @
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
81
|
-
* @param {
|
|
82
|
-
* @param {string} [params.
|
|
83
|
-
* @param {string} [params.
|
|
84
|
-
* @param {string} [params.
|
|
85
|
-
* @param {string} [params.
|
|
86
|
-
* @param {string} [params.
|
|
87
|
-
* @param {string} [params.
|
|
88
|
-
* @param {string} [params.
|
|
89
|
-
* @param {
|
|
90
|
-
* @
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
102
|
-
* @
|
|
103
|
-
* @param {
|
|
104
|
-
* @param {string} [params.
|
|
105
|
-
* @param {string} [params.
|
|
106
|
-
* @param {string} [params.
|
|
107
|
-
* @param {string} [params.
|
|
108
|
-
* @param {string} [params.
|
|
109
|
-
* @param {string} [params.
|
|
110
|
-
* @param {string} [params.
|
|
111
|
-
* @param {
|
|
112
|
-
* @param {
|
|
113
|
-
* @
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @
|
|
128
|
-
* @param {
|
|
129
|
-
* @param {string} params.
|
|
130
|
-
* @param {string
|
|
131
|
-
* @param {string} params.
|
|
132
|
-
* @param {string} [params.
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {
|
|
135
|
-
* @
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*
|
|
149
|
-
* @
|
|
150
|
-
* @
|
|
151
|
-
* @param {
|
|
152
|
-
* @param {string
|
|
153
|
-
* @param {string} params.
|
|
154
|
-
* @param {string
|
|
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 {
|
|
158
|
-
* @
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
+
}
|
package/src/domains/Numbers.js
CHANGED
|
@@ -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
|
}
|