@signalhouse-sms/sdk 1.9.0 → 1.11.0
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/domains/Agents.js +1 -0
- package/src/domains/Messages.js +61 -33
- package/src/domains/Numbers.js +3 -2
- package/src/domains/Rcs.js +192 -7
- package/src/domains/Registrations.js +3 -2
- package/src/domains/Templates.js +13 -4
- package/types/domains/Agents.d.ts +8 -0
- package/types/domains/Messages.d.ts +60 -33
- package/types/domains/Numbers.d.ts +3 -1
- package/types/domains/Rcs.d.ts +272 -7
- package/types/domains/Registrations.d.ts +3 -2
- package/types/domains/Templates.d.ts +50 -7
package/package.json
CHANGED
package/src/domains/Agents.js
CHANGED
|
@@ -158,6 +158,7 @@
|
|
|
158
158
|
* @property {number|null} [maxCallDurationSeconds] - Hard ceiling on one conversation (60-7200).
|
|
159
159
|
* @property {boolean} [allowGreetingInterruption] - Whether a caller may talk over the greeting.
|
|
160
160
|
* @property {string[]} [keyterms] - Words the transcriber is biased toward — names, jargon, unusual spellings.
|
|
161
|
+
* @property {Array<{kind: string, detail?: string|null}>} [allowedCommitments] - SMS channel only: the "a person will..." promises the agent may send on autopilot. Each `kind` is one of "confirm_booking", "call_back", "text_back", "follow_up", "hold_slot" or "send_reminder", listed at most once; `detail` (up to 200 characters) is shown to staff. Any other promise is held for review. Sending a non-empty list on webchat or voice is a 400.
|
|
161
162
|
* @property {Object|null} [backgroundSound] - Ambient audio bed as `{ preset, volume }`; null = silence.
|
|
162
163
|
* @property {AgentWorkflow|null} [workflow] - Conversation workflow graph. Voice channel only — sending one on webchat or sms is a 400. null = no workflow.
|
|
163
164
|
*/
|
package/src/domains/Messages.js
CHANGED
|
@@ -47,12 +47,12 @@ export class Messages {
|
|
|
47
47
|
* @param {string} [params.subgroupId] - Filter messages by the ID of the associated subgroup
|
|
48
48
|
* @param {string} [params.groupId] - Filter messages by the ID of the associated group
|
|
49
49
|
* @param {string|string[]} [params.registrationId] - Filter to messages attributed to these registrations. Cannot be combined with campaignId; each id must belong to the group. Accepts a single value or an array.
|
|
50
|
-
* @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED)
|
|
50
|
+
* @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED; RCS messages also READ, EXPIRED, FALLBACK, BLOCKED)
|
|
51
51
|
* @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
|
|
52
52
|
* @param {string|string[]} [params.messageType] - Filter messages by their type. Accepts a single value or an array (e.g. ["SMS", "MMS"]). Allowed values: SMS, MMS, RCS, WHATSAPP, VIBER, P2P. When omitted, defaults to all non-P2P types.
|
|
53
|
-
* @param {string|string[]} [params.channel] - Filter messages by channel. Accepts a single value or an array. Allowed values: tenDLC, virtualLongCode, tollFree, shortCode, p2p. Each message records its channel when it is saved, and this filters on that stored value; older messages from before this feature have no channel and count as tenDLC. Ignored when matchAny is true (matchAny takes precedence).
|
|
54
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
55
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
53
|
+
* @param {string|string[]} [params.channel] - Filter messages by channel. Accepts a single value or an array. Allowed values: tenDLC, virtualLongCode, tollFree, shortCode, p2p, rcs. Each message records its channel when it is saved, and this filters on that stored value; older messages from before this feature have no channel and count as tenDLC. Ignored when matchAny is true (matchAny takes precedence).
|
|
54
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
55
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
56
56
|
* @param {boolean} [params.matchAny] - When true, the provided campaignId/brandId/phoneNumber filters are OR'd (a message matches ANY of them) instead of the default most-specific-single behavior. subgroupId stays an AND scope. Opt-in/additive.
|
|
57
57
|
* @param {string} [params.carrier] - Filter messages by the carrier used for sending
|
|
58
58
|
* @param {string|string[]} [params.sentimentLabel] - Filter messages by sentiment bucket. Accepts a single value or an array (e.g. ["positive", "negative"]). Allowed values: positive, neutral, negative. Applied as the sentimentScore range the ±25 label threshold produces, so unscored messages match no bucket and outbound messages (never scored) are excluded.
|
|
@@ -67,6 +67,13 @@ export class Messages {
|
|
|
67
67
|
* @param {number} [params.page] - The page number for pagination
|
|
68
68
|
* @param {number} [params.limit] - The number of messages per page
|
|
69
69
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
70
|
+
* @param {string} [params.templateId] - RCS messages sent from this template
|
|
71
|
+
* @param {number} [params.templateVersion] - RCS messages sent from this template version
|
|
72
|
+
* @param {string} [params.bulkId] - The RCS messages of one send
|
|
73
|
+
* @param {string} [params.fallbackReason] - Why an RCS message ran its fallback (NOT_CAPABLE, CARRIER_NOT_LAUNCHED, TTL_EXPIRED, RCS_ERROR, PROVIDER_ERROR, SMS_ONLY)
|
|
74
|
+
* @param {string} [params.billingClass] - Filter by RCS billing class (RICH, RICH_MEDIA)
|
|
75
|
+
* @param {string} [params.deliveredChannel] - Filter by the channel that delivered an RCS message (rcs, sms, mms)
|
|
76
|
+
* @param {boolean} [params.isTest] - true for RCS test messages only, false to leave them out
|
|
70
77
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
71
78
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the list of messages. Inbound messages also carry
|
|
72
79
|
* sentimentScore (-100..100, null when unscored), sentimentLabel ("positive"|"neutral"|"negative", null when
|
|
@@ -99,13 +106,35 @@ export class Messages {
|
|
|
99
106
|
page,
|
|
100
107
|
limit,
|
|
101
108
|
dateBounds,
|
|
109
|
+
templateId,
|
|
110
|
+
templateVersion,
|
|
111
|
+
bulkId,
|
|
112
|
+
fallbackReason,
|
|
113
|
+
billingClass,
|
|
114
|
+
deliveredChannel,
|
|
115
|
+
isTest,
|
|
102
116
|
options = {},
|
|
103
117
|
}) {
|
|
104
|
-
const filters = { id, campaignId, brandId, subgroupId, groupId, registrationId, phoneNumber, senderPhoneNumber, recipientPhoneNumber, status, direction, messageType, channel, region, regionScopes, matchAny, carrier, sentimentLabel, errorCode, startDate, endDate, sortField, sortOrder, page, limit, dateBounds };
|
|
118
|
+
const filters = { id, campaignId, brandId, subgroupId, groupId, registrationId, phoneNumber, senderPhoneNumber, recipientPhoneNumber, status, direction, messageType, channel, region, regionScopes, matchAny, carrier, sentimentLabel, errorCode, startDate, endDate, sortField, sortOrder, page, limit, dateBounds, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest };
|
|
105
119
|
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
106
120
|
return this.client(`/message${queryString}`, { method: "GET", ...options });
|
|
107
121
|
}
|
|
108
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Get one message of any type by its ID
|
|
125
|
+
* @async
|
|
126
|
+
* @roles api, admin, developer, billing, user
|
|
127
|
+
* @param {Object} params - The parameters for getting a message
|
|
128
|
+
* @param {string} params.id - The message ID
|
|
129
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
130
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
131
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the message; an unknown ID is a 404
|
|
132
|
+
*/
|
|
133
|
+
async getMessage({ id, options = {} }) {
|
|
134
|
+
this.client._require({ id });
|
|
135
|
+
return this.client(`/message/${encodeURIComponent(id)}`, { method: "GET", ...options });
|
|
136
|
+
}
|
|
137
|
+
|
|
109
138
|
/**
|
|
110
139
|
* Fetch the latest upstream carrier delivery report for a set of messages by ID.
|
|
111
140
|
* Useful for reconciling messages stuck in a non-terminal state. Outbound SMS and MMS messages sent from numbers on
|
|
@@ -137,17 +166,17 @@ export class Messages {
|
|
|
137
166
|
* @param {string|string[]} [params.subgroupId] - Filter analytics by the ID of the associated subgroup. Accepts a single value, an array, or a comma-separated string.
|
|
138
167
|
* @param {string|string[]} [params.brandId] - Filter analytics by the ID of the associated brand. Accepts a single value, an array, or a comma-separated string.
|
|
139
168
|
* @param {string|string[]} [params.campaignId] - Filter analytics by the ID of the associated campaign. Accepts a single value, an array, or a comma-separated string.
|
|
140
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
169
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
141
170
|
* @param {string|string[]} [params.phoneNumber] - Filter analytics by the phone number involved in the messages. Accepts a single value, an array, or a comma-separated string.
|
|
142
171
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
143
|
-
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics). Accepts a single value, an array, or a comma-separated string.
|
|
172
|
+
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics). Accepts a single value, an array, or a comma-separated string.
|
|
144
173
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
145
174
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back
|
|
146
175
|
* @param {boolean} [params.matchAny] - When true, the provided campaignId/brandId/phoneNumber filters are OR'd (match ANY) instead of the default most-specific-single behavior. subgroupId stays an AND scope. Opt-in/additive.
|
|
147
176
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
148
177
|
* @param {string|string[]} [params.channel] - Filter analytics by channel (tenDLC, virtualLongCode, tollFree, shortCode, p2p). Filters on the stored channel column; a tenDLC selection also includes older messages that have no channel, and p2p is a real channel here (matched by carrier). Accepts a single value or an array. Ignored when matchAny is true (matchAny takes precedence).
|
|
149
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
150
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
178
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
179
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
151
180
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
152
181
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
153
182
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the analytics data. Also includes inbound-message
|
|
@@ -174,18 +203,18 @@ export class Messages {
|
|
|
174
203
|
* @param {string|string[]} [params.subgroupId] - Filter analytics by the ID of the associated subgroup. Accepts a single value, an array, or a comma-separated string.
|
|
175
204
|
* @param {string|string[]} [params.brandId] - Filter analytics by the ID of the associated brand. Accepts a single value, an array, or a comma-separated string.
|
|
176
205
|
* @param {string|string[]} [params.campaignId] - Filter analytics by the ID of the associated campaign. Accepts a single value, an array, or a comma-separated string.
|
|
177
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
206
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
178
207
|
* @param {string|string[]} [params.phoneNumber] - Filter analytics by the phone number involved in the messages. Accepts a single value, an array, or a comma-separated string.
|
|
179
208
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
180
|
-
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics). Accepts a single value, an array, or a comma-separated string.
|
|
209
|
+
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics). Accepts a single value, an array, or a comma-separated string.
|
|
181
210
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp. It is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode, then floored to the start of its hour at either granularity, because the hourly cube is keyed by hour and a mid-hour start would drop that hour's bucket.
|
|
182
211
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp. At day granularity it is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back; at hour granularity it is honoured as given.
|
|
183
212
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
184
213
|
* @param {string|string[]} [params.channel] - Filter analytics by channel (tenDLC, virtualLongCode, tollFree, shortCode, p2p). Filters on the stored channel column; a tenDLC selection also includes older messages that have no channel, and p2p is a real channel here. Accepts a single value or an array.
|
|
185
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
186
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
187
|
-
* @param {("day"|"hour")} [params.granularity] - Time-bucket grain of the byDate rows. Omit for day (each row's _id is a "YYYY-MM-DD" date). "hour" buckets by hour (each row's _id is a "YYYY-MM-DD HH:MM:SS" UTC hour) and is capped to a 7-day span.
|
|
188
|
-
* @param {("carrier"|"carrierFamily")} [params.breakdown] - Adds a byBreakdown time × dimension series to the response ({ dimension, rows }: each row is one byDate bucket (_id) for one carrier or carrier family (key), over the top 50 keys by volume, excluding P2P) and caps the span at 31 days.
|
|
214
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
215
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
216
|
+
* @param {("day"|"hour")} [params.granularity] - Time-bucket grain of the byDate rows. Omit for day (each row's _id is a "YYYY-MM-DD" date). "hour" buckets by hour (each row's _id is a "YYYY-MM-DD HH:MM:SS" UTC hour) and is capped to a 7-day span.
|
|
217
|
+
* @param {("carrier"|"carrierFamily")} [params.breakdown] - Adds a byBreakdown time × dimension series to the response ({ dimension, rows }: each row is one byDate bucket (_id) for one carrier or carrier family (key), over the top 50 keys by volume, excluding P2P) and caps the span at 31 days.
|
|
189
218
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
190
219
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
191
220
|
* @returns {Promise<SdkResponse<Array>>} - A promise that resolves to an array of analytics snapshot records. cardTotals and
|
|
@@ -206,15 +235,14 @@ export class Messages {
|
|
|
206
235
|
* Get per-minute send throughput (peak segments per minute, sending minutes, minutes at a ceiling) for a
|
|
207
236
|
* campaign, brand, or group, per time bucket and per carrier family. Measured from SENT transitions at
|
|
208
237
|
* campaign × carrier-family grain -- the grain carrier ceilings are enforced at -- so a peak here is the
|
|
209
|
-
* figure a ceiling is compared against.
|
|
210
|
-
* elsewhere the request is rejected with a 400.
|
|
238
|
+
* figure a ceiling is compared against.
|
|
211
239
|
* @async
|
|
212
240
|
* @roles api, admin, developer, billing, user
|
|
213
241
|
* @param {Object} params - The parameters for the throughput read
|
|
214
242
|
* @param {string} params.groupId - The group to scope the read to (required)
|
|
215
243
|
* @param {string|string[]} [params.brandId] - Brand scope. Accepts a single value, an array, or a comma-separated string.
|
|
216
244
|
* @param {string|string[]} [params.campaignId] - Campaign scope; wins over brandId. Accepts a single value, an array, or a comma-separated string.
|
|
217
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
245
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. Accepts a single value or an array.
|
|
218
246
|
* @param {string|string[]} [params.carrierFamily] - Carrier-family filter (ATT, TMobile, Verizon, USCellular, ...). Accepts a single value, an array, or a comma-separated string.
|
|
219
247
|
* @param {string} params.startDate - ISO-8601 date or timestamp. It is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode, then floored to the start of its hour at hour granularity and of its minute at day granularity (the cube is keyed by minute).
|
|
220
248
|
* @param {string} params.endDate - ISO-8601 date or timestamp. At hour granularity it is honoured as given; at day granularity it is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back. The span is capped at 35 days (the retention of the per-minute data).
|
|
@@ -237,7 +265,7 @@ export class Messages {
|
|
|
237
265
|
* @roles api, admin, developer, billing, user
|
|
238
266
|
* @param {Object} params - The parameters for getting analytics filter options
|
|
239
267
|
* @param {string} params.groupId - The ID of the group whose filter options to load
|
|
240
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
268
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
241
269
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
242
270
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers, carriers }. Each phone number carries type (TOLL_FREE, SHORT_CODE, ALPHANUMERIC, VIRTUAL_LONG_NUMBER, ...) and country (ISO-2), null when unknown: TOLL_FREE, SHORT_CODE and ALPHANUMERIC are channels by type; any other US number is 10DLC and a non-US one is a Virtual Long Code. `carriers` is a plain array of carrier name strings.
|
|
243
271
|
*/
|
|
@@ -257,10 +285,10 @@ export class Messages {
|
|
|
257
285
|
* @param {string|string[]} [params.subgroupId]
|
|
258
286
|
* @param {string|string[]} [params.brandId]
|
|
259
287
|
* @param {string|string[]} [params.campaignId]
|
|
260
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
288
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
261
289
|
* @param {string|string[]} [params.phoneNumber]
|
|
262
290
|
* @param {string|string[]} [params.carrier]
|
|
263
|
-
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics); single value, array, or comma-separated.
|
|
291
|
+
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics); single value, array, or comma-separated.
|
|
264
292
|
* @param {string} [params.startDate]
|
|
265
293
|
* @param {string} [params.endDate]
|
|
266
294
|
* @param {number} [params.page=1]
|
|
@@ -268,8 +296,8 @@ export class Messages {
|
|
|
268
296
|
* @param {("tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p"|"both")|Array<"tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p">} [params.channel="both"] - Filter and rank rows by the stored channel column. "both" (default) means all activity. tenDLC/virtualLongCode/tollFree/shortCode/p2p (single value or array) limit to the selected channel(s).
|
|
269
297
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
270
298
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
271
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
272
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
299
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
300
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
273
301
|
* @param {RequestOptions} [params.options]
|
|
274
302
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, page, limit }. Each row carries sms/mms/p2p metric columns plus `smsOptOuts` and `mmsOptOuts` from the DNC analytics MV (P2P has no opt-outs).
|
|
275
303
|
* Each row also carries that subgroup's inbound-message sentiment: `sentimentScore` (volume-weighted average of every scored inbound message in that subgroup, -100..100, null when nothing was scored), `sentimentLabel`, `sentimentScoredCount`, `sentimentPositive`, `sentimentNeutral`, `sentimentNegative`, plus the same six per message type under `smsSentiment*`, `mmsSentiment*` and `p2pSentiment*` prefixes. The score is derived server-side and must never be re-averaged across rows — combine the counts, not the scores.
|
|
@@ -290,18 +318,18 @@ export class Messages {
|
|
|
290
318
|
* @param {string|string[]} [params.subgroupId]
|
|
291
319
|
* @param {string|string[]} [params.brandId]
|
|
292
320
|
* @param {string|string[]} [params.campaignId]
|
|
293
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
321
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
294
322
|
* @param {string|string[]} [params.phoneNumber]
|
|
295
323
|
* @param {string|string[]} [params.carrier]
|
|
296
|
-
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics); single value, array, or comma-separated.
|
|
324
|
+
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics); single value, array, or comma-separated.
|
|
297
325
|
* @param {string} [params.startDate]
|
|
298
326
|
* @param {string} [params.endDate]
|
|
299
327
|
* @param {number} [params.page=1]
|
|
300
328
|
* @param {number} [params.limit=50] - max 50 per page
|
|
301
329
|
* @param {("tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p"|"both")|Array<"tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p">} [params.channel="both"] - Filter and rank rows by the stored channel column. "both" (default) means every code. tenDLC/virtualLongCode/tollFree/shortCode/p2p (single value or array) limit to the selected channel(s); when one channel is selected, totalErrors reflects only that channel.
|
|
302
330
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
303
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
304
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
331
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
332
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
305
333
|
* @param {string} [params.errorCode] - Narrow the breakdown to a single failure reason: a numeric Infobip carrier code (as a string, e.g. "607"), the Signal House campaign-opt-out code "OUT", or a no-code failure class (other, moderation, att_limit, p2p_stop, campaign_opt_out, dnc_blocked, bind_hold_expired). Omitted = every reason.
|
|
306
334
|
* @param {RequestOptions} [params.options]
|
|
307
335
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, totalErrors: { sms, mms, p2p, all }, page, limit }
|
|
@@ -321,15 +349,15 @@ export class Messages {
|
|
|
321
349
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
322
350
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
323
351
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
324
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
352
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
325
353
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
326
354
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
327
355
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
328
356
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back
|
|
329
357
|
* @param {string|string[]} [params.channel] - Filter by channel (tenDLC, virtualLongCode, tollFree, shortCode). Opt-outs are A2P-only, so p2p applies no filter. Filters on the stored channel column; a tenDLC selection also includes older opt-outs that have no channel.
|
|
330
358
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
331
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
332
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
359
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
360
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
333
361
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
334
362
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, bySenderNumber, byCampaign, bySubgroup, byType, byCarrier, byKeyword). bySenderNumber ({ senderPhoneNumber, total, sms, mms }) attributes each opt-out to the first business number that received it, so it is unchanged by later campaign moves and START replies. byCampaign ({ campaignId, ... }) counts campaign-scoped opt-outs only, by the campaign at the time of the STOP; subgroup-scoped opt-outs (non-US recipients) are never attributed to a campaign and appear under bySubgroup ({ subgroupId, ... }) instead. byType ({ messageType, total }) splits SMS/MMS. byKeyword breaks opt-outs down by the normalized keyword that revoked consent ({ optOutKeyword, total, sms, mms }); opt-outs recorded before keyword capture shipped appear as a single optOutKeyword: null bucket ("not recorded"). The distinct keyword set is open-ended (campaigns register their own keywords beyond the mandatory floor) — render top-N plus Other, never a fixed list.
|
|
335
363
|
*/
|
|
@@ -348,7 +376,7 @@ export class Messages {
|
|
|
348
376
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
349
377
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
350
378
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
351
|
-
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations
|
|
379
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations. A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
352
380
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
353
381
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
354
382
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
@@ -359,8 +387,8 @@ export class Messages {
|
|
|
359
387
|
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
360
388
|
* @param {string|string[]} [params.channel] - Filter by channel (tenDLC, virtualLongCode, tollFree, shortCode). Opt-outs are A2P-only, so p2p applies no filter. Filters on the stored channel column; a tenDLC selection also includes older opt-outs that have no channel.
|
|
361
389
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
362
|
-
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
363
|
-
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
390
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region.
|
|
391
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string.
|
|
364
392
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
365
393
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the paginated DNC records. Each record carries senderPhoneNumber — the first business number that received the opt-out (set once, never changed by a later STOP or a campaign move; the same value as phoneNumber) — optOutKeyword — the normalized keyword that revoked consent (e.g. "stop", "opt out"; a repeat opt-out records the most recent word), null for opt-outs recorded before keyword capture shipped — and carrierFamily, the resolved carrier family of the recipient number (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, Standard, IceWireless, Bell, Rogers, Telus, Videotron, SaskTel, Eastlink, Fibernetics), copied from the inbound message that triggered the opt-out. campaignId is null on subgroup-scoped records (non-US recipients).
|
|
366
394
|
*/
|
package/src/domains/Numbers.js
CHANGED
|
@@ -87,6 +87,7 @@ export class Numbers {
|
|
|
87
87
|
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
88
88
|
* @param {string} [params.groupId] - Filter by group ID
|
|
89
89
|
* @param {boolean} [params.currentTollFreeCarrier] - With subgroupId or groupId: when true, return only toll-free numbers that a new toll-free campaign in that group can use (those on the group's current toll-free carrier)
|
|
90
|
+
* @param {boolean} [params.released] - With subgroupId or groupId: when true, return only its released numbers (status RELEASED) instead of its active ones
|
|
90
91
|
* @param {number} [params.page] - The page number for pagination (default: 1)
|
|
91
92
|
* @param {number} [params.limit] - The number of items per page for pagination (default: 20)
|
|
92
93
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
@@ -109,8 +110,8 @@ export class Numbers {
|
|
|
109
110
|
* or GET /campaign/health.
|
|
110
111
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of phone numbers
|
|
111
112
|
*/
|
|
112
|
-
async getPhoneNumbers({ phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, currentTollFreeCarrier, page, limit, options = {} }) {
|
|
113
|
-
const filters = { phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, currentTollFreeCarrier, page, limit };
|
|
113
|
+
async getPhoneNumbers({ phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, currentTollFreeCarrier, released, page, limit, options = {} }) {
|
|
114
|
+
const filters = { phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, currentTollFreeCarrier, released, page, limit };
|
|
114
115
|
const queryString = this.client._getQueryString(filters);
|
|
115
116
|
return this.client(`/number${queryString}`, { method: 'GET', ...options });
|
|
116
117
|
}
|
package/src/domains/Rcs.js
CHANGED
|
@@ -47,6 +47,25 @@
|
|
|
47
47
|
* @property {string} [mobile] - Mobile number, E.164
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* One recipient of an RCS send.
|
|
52
|
+
* @typedef {Object} RcsRecipient
|
|
53
|
+
* @property {string} phoneNumber - The number, 10-15 digits, with or without the +
|
|
54
|
+
* @property {Object<string, string>} [variables] - Template variable values for this recipient
|
|
55
|
+
* @property {string} [clientMessageId] - Your reference for this message (max 128)
|
|
56
|
+
* @property {Object<string, string>} [metadata] - Your key-value data (up to 20 keys, values up to 500 characters)
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* What an RCS send does when RCS cannot reach a recipient.
|
|
61
|
+
* @typedef {Object} RcsMessageFallback
|
|
62
|
+
* @property {("auto"|"rcs_only"|"sms_only")} [mode] - The fallback mode
|
|
63
|
+
* @property {("auto"|"sms"|"mms")} [channel] - The fallback channel
|
|
64
|
+
* @property {string} [from] - The sender: a Ready number on the agent's linked Active campaign
|
|
65
|
+
* @property {{ text: string, mediaUrls?: string[] }} [content] - The fallback text; omitted, the template's fallback, else a generated one, is used
|
|
66
|
+
* @property {number} [validitySeconds] - How long the fallback message stays valid, in seconds
|
|
67
|
+
*/
|
|
68
|
+
|
|
50
69
|
/**
|
|
51
70
|
* Build the multipart form for an agent image upload.
|
|
52
71
|
* @param {Object} params - Form fields
|
|
@@ -64,7 +83,7 @@ export function agentAssetForm({ kind, file, fileName }) {
|
|
|
64
83
|
}
|
|
65
84
|
|
|
66
85
|
/**
|
|
67
|
-
* RCS agents under /rcs/agent. An agent links one
|
|
86
|
+
* RCS agents under /rcs/agent. An agent links one brand and one campaign, of any registration type: the campaign's numbers are the
|
|
68
87
|
* SMS fallback, and the brand and campaign supply the company identity and consent text for the carrier launch.
|
|
69
88
|
* One brand or campaign can serve many agents. An agent is a registration (type RCS_AGENT, id RCSA…), so the
|
|
70
89
|
* registrations methods read and edit the same record. 404 while the environment's RCS switch is off; 400 while the
|
|
@@ -77,13 +96,13 @@ export class RcsAgents {
|
|
|
77
96
|
}
|
|
78
97
|
|
|
79
98
|
/**
|
|
80
|
-
* Create an agent draft on a
|
|
99
|
+
* Create an agent draft on a brand, optionally with its campaign. The agent's subgroup is the brand's.
|
|
81
100
|
* Blank consent fields fill from the linked campaign. Pass options.idempotencyKey to make a retry safe.
|
|
82
101
|
* @async
|
|
83
102
|
* @roles api, admin, developer, billing, user
|
|
84
103
|
* @param {Object} params - The agent
|
|
85
|
-
* @param {string} params.brandId - The
|
|
86
|
-
* @param {string|null} [params.campaignId] - A
|
|
104
|
+
* @param {string} params.brandId - The brand: carrier brand ID, provisional UUID or _id
|
|
105
|
+
* @param {string|null} [params.campaignId] - A campaign of that brand: campaign ID or _id; required before submit
|
|
87
106
|
* @param {RcsAgentProfile} [params.agent] - The agent profile
|
|
88
107
|
* @param {RcsAgentConsent} [params.consent] - The launch text; required in full before the launch request
|
|
89
108
|
* @param {RcsAgentContact} [params.contact] - The launch contact; required in full before the launch request
|
|
@@ -112,8 +131,8 @@ export class RcsAgents {
|
|
|
112
131
|
* @param {string} [params.groupId] - Filter by group ID
|
|
113
132
|
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
114
133
|
* @param {string|string[]} [params.status] - DRAFT, PENDING_REVIEW, REJECTED, AGENT_CREATING or ARCHIVED, one or a list
|
|
115
|
-
* @param {string} [params.brandId] - Agents linked to this
|
|
116
|
-
* @param {string} [params.campaignId] - Agents linked to this
|
|
134
|
+
* @param {string} [params.brandId] - Agents linked to this brand (carrier brand ID, provisional UUID or _id)
|
|
135
|
+
* @param {string} [params.campaignId] - Agents linked to this campaign (campaign ID or _id)
|
|
117
136
|
* @param {number} [params.page] - Page number (default 1)
|
|
118
137
|
* @param {number} [params.limit] - Agents per page (default 25, max 100)
|
|
119
138
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
@@ -147,7 +166,7 @@ export class RcsAgents {
|
|
|
147
166
|
* @roles api, admin, developer, billing, user
|
|
148
167
|
* @param {Object} params - The edit
|
|
149
168
|
* @param {string} params.agentId - The agent ID
|
|
150
|
-
* @param {string} [params.brandId] - Relink to another
|
|
169
|
+
* @param {string} [params.brandId] - Relink to another brand of the same subgroup
|
|
151
170
|
* @param {string|null} [params.campaignId] - Link, relink or (null) unlink the campaign
|
|
152
171
|
* @param {RcsAgentProfile} [params.agent] - Profile fields to change
|
|
153
172
|
* @param {RcsAgentConsent} [params.consent] - Consent fields to change
|
|
@@ -206,6 +225,7 @@ export class RcsAgents {
|
|
|
206
225
|
* PENDING_REVIEW), whose approval files the launch with the carrier partner. Allowed from IN_TESTING, REJECTED and
|
|
207
226
|
* CARRIER_REJECTED (409 otherwise); a failed requirement is a 400 whose details carry { code:
|
|
208
227
|
* "REGISTRATION_INCOMPLETE", errors, warnings }. Sends POST /registration/:agentId/launch: the agent is a registration.
|
|
228
|
+
* The request charges the agent's launch fees: a wallet that cannot cover them gets a 402, and the agent stays where it is. The agent's launchFees quotes what the next request charges.
|
|
209
229
|
* @async
|
|
210
230
|
* @roles api, admin, developer, billing, user
|
|
211
231
|
* @param {Object} params - The launch request
|
|
@@ -271,11 +291,176 @@ export class RcsAgents {
|
|
|
271
291
|
}
|
|
272
292
|
}
|
|
273
293
|
|
|
294
|
+
/**
|
|
295
|
+
* RCS messages. Sends go through an agent to POST /message/rcs. A message is a Message record (messageType RCS), so the
|
|
296
|
+
* messages methods read the same record. 404 while the environment's RCS switch is off; 403 while the group's rcsEnabled
|
|
297
|
+
* flag is off; 409 while the agent cannot send yet.
|
|
298
|
+
*/
|
|
299
|
+
export class RcsMessages {
|
|
300
|
+
/**
|
|
301
|
+
* Keep the JSON client every RCS message request goes through.
|
|
302
|
+
* @param {any} client - The JSON request client
|
|
303
|
+
*/
|
|
304
|
+
constructor(client) {
|
|
305
|
+
this.client = client;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Send an RCS message to up to 100 recipients. A check that blocks one recipient writes a BLOCKED message for it and the
|
|
310
|
+
* rest still send. Pass options.idempotencyKey to make a retry safe.
|
|
311
|
+
* @async
|
|
312
|
+
* @roles api, admin, developer, billing, user
|
|
313
|
+
* @param {Object} params - The send
|
|
314
|
+
* @param {string} params.agentId - The agent that sends (RCSA…)
|
|
315
|
+
* @param {RcsRecipient[]} params.recipients - Up to 100 recipients
|
|
316
|
+
* @param {string} [params.templateId] - A template to send; exactly one of templateId or content
|
|
317
|
+
* @param {number} [params.templateVersion] - A published version of templateId; needs templateId
|
|
318
|
+
* @param {Object} [params.content] - Inline content; exactly one of templateId or content
|
|
319
|
+
* @param {string} [params.contentFormat] - content.v1 (default) or google.rcs
|
|
320
|
+
* @param {("AUTHENTICATION"|"TRANSACTION"|"SERVICEREQUEST"|"ACKNOWLEDGEMENT"|"PROMOTION")} [params.trafficType] - Required on a MULTI_USE agent when the template sets none
|
|
321
|
+
* @param {number} [params.ttlSeconds] - Seconds the RCS message may wait for delivery; at most one of ttlSeconds or expireTime
|
|
322
|
+
* @param {string} [params.expireTime] - ISO-8601 time the RCS message expires
|
|
323
|
+
* @param {RcsMessageFallback} [params.fallback] - The fallback for this send
|
|
324
|
+
* @param {string} [params.statusCallbackUrl] - URL that receives this message's status events
|
|
325
|
+
* @param {boolean} [params.enableShortlink] - Shorten the links in the message
|
|
326
|
+
* @param {boolean} [params.isTest] - Send as a test; approved testers only
|
|
327
|
+
* @param {("not_capable"|"ttl_expired"|"delivered"|"read")} [params.simulate] - Simulate this outcome; approved testers only
|
|
328
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
329
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { requested, enqueued, failed, bulkId, messages } (201). A blocked row carries blockReason, reason and issues; an archived template answers 409 TEMPLATE_ARCHIVED
|
|
330
|
+
*/
|
|
331
|
+
async send({ agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate, options = {} }) {
|
|
332
|
+
this.client._require({ agentId, recipients });
|
|
333
|
+
return this.client("/message/rcs", {
|
|
334
|
+
method: "POST",
|
|
335
|
+
body: { agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate },
|
|
336
|
+
...options,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Check a send without writing anything. Takes the same parameters as send.
|
|
342
|
+
* @async
|
|
343
|
+
* @roles api, admin, developer, billing, user
|
|
344
|
+
* @param {Object} params - The send to check
|
|
345
|
+
* @param {string} params.agentId - The agent that sends (RCSA…)
|
|
346
|
+
* @param {RcsRecipient[]} params.recipients - Up to 100 recipients
|
|
347
|
+
* @param {string} [params.templateId] - A template to send; exactly one of templateId or content
|
|
348
|
+
* @param {number} [params.templateVersion] - A published version of templateId; needs templateId
|
|
349
|
+
* @param {Object} [params.content] - Inline content; exactly one of templateId or content
|
|
350
|
+
* @param {string} [params.contentFormat] - content.v1 (default) or google.rcs
|
|
351
|
+
* @param {("AUTHENTICATION"|"TRANSACTION"|"SERVICEREQUEST"|"ACKNOWLEDGEMENT"|"PROMOTION")} [params.trafficType] - Required on a MULTI_USE agent when the template sets none
|
|
352
|
+
* @param {number} [params.ttlSeconds] - Seconds the RCS message may wait for delivery; at most one of ttlSeconds or expireTime
|
|
353
|
+
* @param {string} [params.expireTime] - ISO-8601 time the RCS message expires
|
|
354
|
+
* @param {RcsMessageFallback} [params.fallback] - The fallback for this send
|
|
355
|
+
* @param {string} [params.statusCallbackUrl] - URL that receives this message's status events
|
|
356
|
+
* @param {boolean} [params.enableShortlink] - Shorten the links in the message
|
|
357
|
+
* @param {boolean} [params.isTest] - Send as a test; approved testers only
|
|
358
|
+
* @param {("not_capable"|"ttl_expired"|"delivered"|"read")} [params.simulate] - Simulate this outcome; approved testers only
|
|
359
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
360
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { valid, errors, warnings, billingClass, segments, estimatedCostMicros, unsupportedFiles, recipients }. valid is true only with no errors; each blocked recipient adds an error and carries blockReason, reason and issues
|
|
361
|
+
*/
|
|
362
|
+
async validate({ agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate, options = {} }) {
|
|
363
|
+
this.client._require({ agentId, recipients });
|
|
364
|
+
return this.client("/message/rcs/validate", {
|
|
365
|
+
method: "POST",
|
|
366
|
+
body: { agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate },
|
|
367
|
+
...options,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Price an RCS draft; no charge or send. Sends POST /message/estimate with channel "rcs". Amounts are microdollars.
|
|
373
|
+
* @async
|
|
374
|
+
* @roles api, admin, developer, billing, user
|
|
375
|
+
* @param {Object} params - The draft
|
|
376
|
+
* @param {string} params.agentId - The agent that would send (RCSA…)
|
|
377
|
+
* @param {RcsRecipient[]} [params.recipients] - Named recipients; exactly one of recipients or recipientCount
|
|
378
|
+
* @param {number} [params.recipientCount] - A recipient count; carriers are unknown, so the default fees apply
|
|
379
|
+
* @param {string} [params.templateId] - A template to price; exactly one of templateId or content
|
|
380
|
+
* @param {number} [params.templateVersion] - A published version of templateId; needs templateId
|
|
381
|
+
* @param {Object} [params.content] - Inline content; exactly one of templateId or content
|
|
382
|
+
* @param {string} [params.contentFormat] - content.v1 (default) or google.rcs
|
|
383
|
+
* @param {("AUTHENTICATION"|"TRANSACTION"|"SERVICEREQUEST"|"ACKNOWLEDGEMENT"|"PROMOTION")} [params.trafficType] - Required on a MULTI_USE agent when the template sets none
|
|
384
|
+
* @param {number} [params.ttlSeconds] - Seconds the RCS message may wait for delivery; at most one of ttlSeconds or expireTime
|
|
385
|
+
* @param {string} [params.expireTime] - ISO-8601 time the RCS message expires
|
|
386
|
+
* @param {RcsMessageFallback} [params.fallback] - The fallback to price; its from is optional here, and with none the leg is priced on the channel of the agent's linked campaign
|
|
387
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
388
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { billingClass, segments, recipientCount, rcsLeg, fallbackLeg, totals, balance, issues, warnings }; rcsLeg.mediaSurcharge is the carrier's surcharge on media over 5 MB, already inside rcsLeg.cost; a message over 100 MB adds a MEDIA_TOO_LARGE issue.
|
|
389
|
+
*/
|
|
390
|
+
async estimate({ agentId, recipients, recipientCount, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, options = {} }) {
|
|
391
|
+
this.client._require({ agentId });
|
|
392
|
+
return this.client("/message/estimate", {
|
|
393
|
+
method: "POST",
|
|
394
|
+
body: { channel: "rcs", agentId, recipients, recipientCount, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback },
|
|
395
|
+
...options,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Report which numbers can receive RCS from an agent
|
|
401
|
+
* @async
|
|
402
|
+
* @roles api, admin, developer, billing, user
|
|
403
|
+
* @param {Object} params - The lookup
|
|
404
|
+
* @param {string} params.agentId - The agent (RCSA…)
|
|
405
|
+
* @param {string[]} params.phoneNumbers - Up to 500 numbers, 10-15 digits, with or without the +
|
|
406
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
407
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { results: [{ phoneNumber, capability }] }, capability being ENABLED, UNREACHABLE or UNKNOWN
|
|
408
|
+
*/
|
|
409
|
+
async capabilities({ agentId, phoneNumbers, options = {} }) {
|
|
410
|
+
this.client._require({ agentId, phoneNumbers });
|
|
411
|
+
return this.client("/rcs/capabilities", { method: "POST", body: { agentId, phoneNumbers }, ...options });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get one message by its ID. The same route as messages.getMessage.
|
|
416
|
+
* @async
|
|
417
|
+
* @roles api, admin, developer, billing, user
|
|
418
|
+
* @param {Object} params - The lookup
|
|
419
|
+
* @param {string} params.messageId - The message ID
|
|
420
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
421
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the message; an unknown ID is a 404
|
|
422
|
+
*/
|
|
423
|
+
async get({ messageId, options = {} }) {
|
|
424
|
+
this.client._require({ messageId });
|
|
425
|
+
return this.client(`/message/${encodeURIComponent(messageId)}`, { method: "GET", ...options });
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* List RCS messages. Sends GET /message with messageType RCS. A fallback leg is an SMS or MMS message: read it with
|
|
430
|
+
* messages.getMessage and the parent's fallbackMessageId.
|
|
431
|
+
* @async
|
|
432
|
+
* @roles api, admin, developer, billing, user
|
|
433
|
+
* @param {Object} params - The group, the date range and the filters
|
|
434
|
+
* @param {string} params.groupId - The group whose messages to list
|
|
435
|
+
* @param {string} params.from - ISO-8601 date or timestamp; sent as startDate
|
|
436
|
+
* @param {string} params.to - ISO-8601 date or timestamp; sent as endDate
|
|
437
|
+
* @param {string} [params.agentId] - Messages this agent sent; sent as registrationId
|
|
438
|
+
* @param {string} [params.status] - Filter by status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED, READ, EXPIRED, FALLBACK, BLOCKED)
|
|
439
|
+
* @param {number} [params.page] - Page number
|
|
440
|
+
* @param {number} [params.limit] - Messages per page
|
|
441
|
+
* @param {string} [params.templateId] - Messages sent from this template
|
|
442
|
+
* @param {number} [params.templateVersion] - Messages sent from this template version
|
|
443
|
+
* @param {string} [params.bulkId] - Messages of one send
|
|
444
|
+
* @param {string} [params.fallbackReason] - Why the fallback ran (NOT_CAPABLE, CARRIER_NOT_LAUNCHED, TTL_EXPIRED, RCS_ERROR, PROVIDER_ERROR, SMS_ONLY)
|
|
445
|
+
* @param {string} [params.billingClass] - Filter by billing class (RICH, RICH_MEDIA)
|
|
446
|
+
* @param {string} [params.deliveredChannel] - Filter by the channel that delivered the message (rcs, sms, mms)
|
|
447
|
+
* @param {boolean} [params.isTest] - true for test messages only, false to leave them out
|
|
448
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
449
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of messages
|
|
450
|
+
*/
|
|
451
|
+
async list({ groupId, from, to, agentId, status, page, limit, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest, options = {} }) {
|
|
452
|
+
this.client._require({ groupId, from, to });
|
|
453
|
+
const queryString = this.client._getQueryString({ registrationId: agentId, startDate: from, endDate: to, groupId, status, page, limit, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest, messageType: "RCS" });
|
|
454
|
+
return this.client(`/message${queryString}`, { method: "GET", ...options });
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
274
458
|
/**
|
|
275
459
|
* RCS (Google RBM) resources. Templates for RCS live under `templates`.
|
|
276
460
|
*/
|
|
277
461
|
export class Rcs {
|
|
278
462
|
constructor(client, multipartClient) {
|
|
279
463
|
this.agents = new RcsAgents(client, multipartClient);
|
|
464
|
+
this.messages = new RcsMessages(client);
|
|
280
465
|
}
|
|
281
466
|
}
|
|
@@ -171,8 +171,8 @@ export class Registrations {
|
|
|
171
171
|
* @param {string|string[]} [params.status] - Filter by one registration status or a list
|
|
172
172
|
* @param {string} [params.parentRegistrationId] - Filter by the parent registration ID
|
|
173
173
|
* @param {string} [params.phoneNumber] - Filter to registrations holding this phone number
|
|
174
|
-
* @param {string} [params.brandId] - RCS agents only: filter to agents linked to this
|
|
175
|
-
* @param {string} [params.campaignId] - RCS agents only: filter to agents linked to this
|
|
174
|
+
* @param {string} [params.brandId] - RCS agents only: filter to agents linked to this brand (carrier id, provisional UUID or _id)
|
|
175
|
+
* @param {string} [params.campaignId] - RCS agents only: filter to agents linked to this campaign (campaign id or _id)
|
|
176
176
|
* @param {string} [params.sortBy] - Sort field: createdAt (default), subgroupId, registrationId, region or status
|
|
177
177
|
* @param {string} [params.sortOrder] - Sort direction: asc or desc (default)
|
|
178
178
|
* @param {number} [params.page] - Page number (default 1)
|
|
@@ -257,6 +257,7 @@ export class Registrations {
|
|
|
257
257
|
* Allowed while the provider reports the agent ready for testing, after a Signal House rejection, or after every
|
|
258
258
|
* carrier refused an earlier launch (409 otherwise); a failed requirement is a 400 whose details carry
|
|
259
259
|
* { code: "REGISTRATION_INCOMPLETE", errors, warnings }.
|
|
260
|
+
* An RCS agent's launch request charges its launch fees: a wallet that cannot cover them gets a 402, and nothing changes.
|
|
260
261
|
* @async
|
|
261
262
|
* @roles api, admin, developer, billing, user
|
|
262
263
|
* @param {Object} params - The parameters for the launch request
|