@signalhouse-sms/sdk 1.11.0 → 1.13.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/SignalHouseSDK.js +5 -0
- package/src/domains/Audit.js +39 -0
- package/src/domains/Billing.js +5 -2
- package/src/domains/Brands.js +56 -1
- package/src/domains/Campaigns.js +2 -2
- package/src/domains/Messages.js +52 -1
- package/src/domains/Numbers.js +4 -3
- package/src/domains/Rcs.js +158 -24
- package/src/domains/Registrations.js +112 -8
- package/src/domains/Templates.js +2 -0
- package/src/domains/Verify.js +72 -0
- package/src/domains/Webhooks.js +9 -5
- package/types/SignalHouseSDK.d.ts +4 -0
- package/types/domains/Audit.d.ts +39 -0
- package/types/domains/Billing.d.ts +7 -1
- package/types/domains/Brands.d.ts +64 -1
- package/types/domains/Campaigns.d.ts +2 -2
- package/types/domains/Messages.d.ts +67 -1
- package/types/domains/Numbers.d.ts +4 -3
- package/types/domains/Rcs.d.ts +198 -20
- package/types/domains/Registrations.d.ts +92 -6
- package/types/domains/Templates.d.ts +2 -0
- package/types/domains/Verify.d.ts +71 -0
- package/types/domains/Webhooks.d.ts +9 -4
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -47,6 +47,8 @@ import { Notifications } from "./domains/Notifications.js";
|
|
|
47
47
|
import { Webhooks } from "./domains/Webhooks.js";
|
|
48
48
|
import { Voice } from "./domains/Voice.js";
|
|
49
49
|
import { Agents } from "./domains/Agents.js";
|
|
50
|
+
import { Audit } from "./domains/Audit.js";
|
|
51
|
+
import { Verify } from "./domains/Verify.js";
|
|
50
52
|
|
|
51
53
|
export class SignalHouseSDK {
|
|
52
54
|
/**
|
|
@@ -98,6 +100,9 @@ export class SignalHouseSDK {
|
|
|
98
100
|
this.voice = new Voice(client, this.enableAdmin);
|
|
99
101
|
// AI Agents domain — customer-facing agent config under /agent.
|
|
100
102
|
this.agents = new Agents(client, this.enableAdmin);
|
|
103
|
+
this.audit = new Audit(client, this.enableAdmin);
|
|
104
|
+
// Carrier phone-number checks (SIM Swap, Number Verify) under /verify.
|
|
105
|
+
this.verify = new Verify(client, this.enableAdmin);
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Audit domain: the staff read of who changed a registration or a message template, and what changed. Every method lives
|
|
9
|
+
* under the admin namespace, present only when the SDK is created with `enableAdmin: true`.
|
|
10
|
+
*/
|
|
11
|
+
export class Audit {
|
|
12
|
+
constructor(client, enableAdmin) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.enableAdmin = enableAdmin;
|
|
15
|
+
|
|
16
|
+
// Hidden Admin namespace INSIDE the domain
|
|
17
|
+
if (enableAdmin) {
|
|
18
|
+
this.admin = {
|
|
19
|
+
/**
|
|
20
|
+
* Get audit events, newest first: one registration's or template's, or a group's. Staff-only.
|
|
21
|
+
* @async
|
|
22
|
+
* @roles signalhouse
|
|
23
|
+
* @param {Object} params
|
|
24
|
+
* @param {("registration"|"template")} [params.entityType] - The entity type; required with entityId
|
|
25
|
+
* @param {string} [params.entityId] - The registration id or template id
|
|
26
|
+
* @param {string} [params.groupId] - The owning group; required when entityId is omitted
|
|
27
|
+
* @param {number} [params.page] - Page number (default 1)
|
|
28
|
+
* @param {number} [params.limit] - Events per page (default 25, max 100)
|
|
29
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
30
|
+
* @returns {Promise<SdkResponse<any>>} - `{ data, total, page, limit }`; each event is `{ _id, occurredAt, actor: { type, userId, role }, entity: { type, id, groupId }, action, changes: [{ path, from, to }] }`
|
|
31
|
+
*/
|
|
32
|
+
getAuditEvents: async ({ entityType, entityId, groupId, page, limit, options = {} } = {}) => {
|
|
33
|
+
const queryString = this.client._getQueryString({ entityType, entityId, groupId, page, limit });
|
|
34
|
+
return this.client(`/audit${queryString}`, { method: "GET", ...options });
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/domains/Billing.js
CHANGED
|
@@ -70,11 +70,14 @@ export class Billing {
|
|
|
70
70
|
* @param {string} [params.transactionType] - The type of transaction to filter by
|
|
71
71
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; normalized to start-of-UTC-day (inclusive)
|
|
72
72
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp; normalized to end-of-UTC-day (inclusive). Hourly resolution is not supported
|
|
73
|
+
* @param {string} [params.category] - One category, or a comma-separated list: one of the RCS categories RCS_RICH_OUTBOUND, RCS_RICH_MEDIA_OUTBOUND, RCS_INBOUND, RCS_ACTION_CLICK, RCS_MEDIA_SURCHARGE, RCS_FEE_ONBOARDING, RCS_FEE_RENEWAL, RCS_SESSION_ADJUSTMENT or RCS_SESSION_CARRIER_ADJUSTMENT, or RCS_CARRIER_PASSTHROUGH for RCS carrier rows alone. Any other value is rejected with a 400.
|
|
74
|
+
* @param {number} [params.page] - Page number (positive integer)
|
|
75
|
+
* @param {number} [params.limit] - Page size, at most 1000
|
|
73
76
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
74
77
|
* @returns {Promise<SdkResponse<Array>>} The response from the server
|
|
75
78
|
*/
|
|
76
|
-
async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, options = {} }) {
|
|
77
|
-
const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate };
|
|
79
|
+
async getTransactionHistory({ groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, category, page, limit, options = {} }) {
|
|
80
|
+
const filters = { groupId, subgroupId, brandId, campaignId, entryType, transactionType, startDate, endDate, category, page, limit };
|
|
78
81
|
const queryString = this.client._getQueryString(filters);
|
|
79
82
|
return this.client(`/billing/wallet/transactionHistory${queryString}`, { method: "GET", ...options });
|
|
80
83
|
}
|
package/src/domains/Brands.js
CHANGED
|
@@ -225,7 +225,7 @@ export class Brands {
|
|
|
225
225
|
* @param {boolean} [params.excludeDeleted] - Staff-only: hide DELETED brands when no status is given
|
|
226
226
|
* @param {boolean} [params.includeTotal] - Staff-only: with page and limit, return `{ data, total, page, limit, totalPages }` instead of the array
|
|
227
227
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
228
|
-
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, tollFree?: { isBrandReady?: boolean, maxNumbersPerCampaign?: number, maxOptInMethods?: number, requiresPrivacyPolicy?: boolean, requiresTermsAndConditions?: boolean, maxAppealReasonLength?: number, labelsSamples?: boolean, supportsMms?: boolean, reviewsBusinessOnSubmit?: boolean, businessStructure?: string|null, industry?: string|null, contactEmail?: string|null, contactJobTitle?: string|null, contactJobLevel?: string|null, rejectionReason?: string|null, [key: string]: any }, [key: string]: any }>|{ data: Array<Object>, total: number, page: number, limit: number, totalPages: number }>>} Brand records. For 10DLC brands in PENDING_CREATION (or rejected before carrier assignment), brandId is null — poll by _id until status advances and brandId is assigned. Toll-free brands carry `tollFree.isBrandReady` (whether the brand can host campaigns), `tollFree.maxNumbersPerCampaign` (the most numbers one of its campaigns can hold), `tollFree.maxOptInMethods` (the most opt-in methods one of its campaigns can declare), `tollFree.requiresPrivacyPolicy` (whether its campaigns need a privacy policy URL), `tollFree.requiresTermsAndConditions` (whether its campaigns need a terms and conditions URL), `tollFree.maxAppealReasonLength` (the longest appeal reason its campaigns may give), `tollFree.labelsSamples` (whether its campaigns' sample messages each start with their use case's name), `tollFree.supportsMms` (whether its numbers can send MMS and group messages) and `tollFree.reviewsBusinessOnSubmit` (whether it's reviewed when it's submitted and keeps its business details from then on). A brand reviewed on submit also carries its `tollFree.businessStructure`, `tollFree.industry`, `tollFree.contactEmail`, `tollFree.contactJobTitle` and `tollFree.contactJobLevel`, and `tollFree.rejectionReason` (why its review rejected it, in plain English, or null). On other toll-free brands these are null or absent. The staff-only list (no id/subgroupId/groupId) returns the `{ data, total, page, limit, totalPages }` envelope only when includeTotal is sent with page and limit. Each brand carries `carrierSuspensions` (carrier brand suspension rules; active while liftedAt is null).
|
|
228
|
+
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, tollFree?: { isBrandReady?: boolean, maxNumbersPerCampaign?: number, maxOptInMethods?: number, requiresPrivacyPolicy?: boolean, requiresTermsAndConditions?: boolean, maxAppealReasonLength?: number, labelsSamples?: boolean, supportsMms?: boolean, reviewsBusinessOnSubmit?: boolean, businessStructure?: string|null, industry?: string|null, contactEmail?: string|null, contactJobTitle?: string|null, contactJobLevel?: string|null, rejectionReason?: string|null, [key: string]: any }, [key: string]: any }>|{ data: Array<Object>, total: number, page: number, limit: number, totalPages: number }>>} Brand records. For 10DLC brands in PENDING_CREATION (or rejected before carrier assignment), brandId is null — poll by _id until status advances and brandId is assigned. Toll-free brands carry `tollFree.isBrandReady` (whether the brand can host campaigns), `tollFree.maxNumbersPerCampaign` (the most numbers one of its campaigns can hold), `tollFree.maxOptInMethods` (the most opt-in methods one of its campaigns can declare), `tollFree.requiresPrivacyPolicy` (whether its campaigns need a privacy policy URL), `tollFree.requiresTermsAndConditions` (whether its campaigns need a terms and conditions URL), `tollFree.maxAppealReasonLength` (the longest appeal reason its campaigns may give), `tollFree.labelsSamples` (whether its campaigns' sample messages each start with their use case's name), `tollFree.supportsMms` (whether its numbers can send MMS and group messages) and `tollFree.reviewsBusinessOnSubmit` (whether it's reviewed when it's submitted and keeps its business details from then on). A brand reviewed on submit also carries its `tollFree.businessStructure`, `tollFree.industry`, `tollFree.contactEmail`, `tollFree.contactJobTitle` and `tollFree.contactJobLevel`, and `tollFree.rejectionReason` (why its review rejected it, in plain English, or null). On other toll-free brands these are null or absent. The staff-only list (no id/subgroupId/groupId) returns the `{ data, total, page, limit, totalPages }` envelope only when includeTotal is sent with page and limit. Each brand carries `carrierSuspensions` (carrier brand suspension rules; active while liftedAt is null). Each brand also carries `cnamName` (its caller name for numbers, or null; see getCallerName).
|
|
229
229
|
*/
|
|
230
230
|
async getBrands({
|
|
231
231
|
id,
|
|
@@ -541,4 +541,59 @@ export class Brands {
|
|
|
541
541
|
formData.append('file', file);
|
|
542
542
|
return this.multipartClient(`/brand/appeal/${safeBrandId}`, { method: 'POST', body: formData, ...options });
|
|
543
543
|
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Get a brand's caller name (CNAM) and the numbers it applies to: every number whose caller name comes from this
|
|
547
|
+
* brand (its campaign numbers, numbers it was picked on, and campaign-less numbers of subgroups that use it as
|
|
548
|
+
* their default caller-ID brand)
|
|
549
|
+
* @async
|
|
550
|
+
* @roles api, admin, developer, billing, user
|
|
551
|
+
* @param {Object} params - The parameters for the request
|
|
552
|
+
* @param {BrandLookupId} params.brandId - Brand lookup id (carrier Brand ID, record `_id`, or internal reference).
|
|
553
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
554
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
555
|
+
* @returns {Promise<SdkResponse<{ brandId: string, companyName: string, cnamName: string|null, eligible: boolean, numbers: { total: number, items: Array<{ phoneNumber: string, friendlyName: string|null, cnam: Object|null }> } }>>} The brand's caller name (null when it has none) and its numbers; `items` lists the first 100
|
|
556
|
+
*/
|
|
557
|
+
async getCallerName({ brandId, options = {} }) {
|
|
558
|
+
this.client._require({ brandId });
|
|
559
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
560
|
+
return this.client(`/brand/cnam/${safeBrandId}`, { method: 'GET', ...options });
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Set a brand's caller name (CNAM). It replaces the caller name on every number whose caller name comes from this
|
|
565
|
+
* brand, names set on a number included, and numbers that later come under the brand get it too. The name may only
|
|
566
|
+
* remove characters from the brand's registered name and must be 1-15 letters, digits, spaces, `-` or `_`; the brand
|
|
567
|
+
* must be verified. Numbers are updated at the carrier in the background (their `cnam.status` is PENDING until then).
|
|
568
|
+
* @async
|
|
569
|
+
* @roles api, admin, developer
|
|
570
|
+
* @param {Object} params - The parameters for the request
|
|
571
|
+
* @param {BrandLookupId} params.brandId - Brand lookup id (carrier Brand ID, record `_id`, or internal reference).
|
|
572
|
+
* @param {string} params.name - The caller name to show
|
|
573
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
574
|
+
* @throws {Error} Throws an error if the brandId or name parameter is missing
|
|
575
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ brandId, companyName, cnamName, eligible, numbers: { total, items } }`
|
|
576
|
+
*/
|
|
577
|
+
async setCallerName({ brandId, name, options = {} }) {
|
|
578
|
+
this.client._require({ brandId, name });
|
|
579
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
580
|
+
return this.client(`/brand/cnam/${safeBrandId}`, { method: 'PUT', body: { name }, ...options });
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Remove a brand's caller name (CNAM). Numbers that had it go back to the automatic name if their subgroup has
|
|
585
|
+
* caller name auto-apply on, otherwise to no caller name. Names set on a number are kept.
|
|
586
|
+
* @async
|
|
587
|
+
* @roles api, admin, developer
|
|
588
|
+
* @param {Object} params - The parameters for the request
|
|
589
|
+
* @param {BrandLookupId} params.brandId - Brand lookup id (carrier Brand ID, record `_id`, or internal reference).
|
|
590
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
591
|
+
* @throws {Error} Throws an error if the brandId parameter is missing
|
|
592
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ brandId, companyName, cnamName, eligible, numbers: { total, items } }`
|
|
593
|
+
*/
|
|
594
|
+
async deleteCallerName({ brandId, options = {} }) {
|
|
595
|
+
this.client._require({ brandId });
|
|
596
|
+
const safeBrandId = encodeURIComponent(brandId);
|
|
597
|
+
return this.client(`/brand/cnam/${safeBrandId}`, { method: 'DELETE', ...options });
|
|
598
|
+
}
|
|
544
599
|
}
|
package/src/domains/Campaigns.js
CHANGED
|
@@ -425,7 +425,7 @@ export class Campaigns {
|
|
|
425
425
|
* @param {string} params.campaignId - Campaign identifier
|
|
426
426
|
* @param {RequestOptions} [params.options] - Additional request options
|
|
427
427
|
* @throws {Error} Throws an error if the campaignId parameter is missing
|
|
428
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ campaignId, brandId, usecase, brand: { status, brandScore, entityType }, att: { tier, scope, unit, sms: { limit }, mms: { limit }, marginPercent, nextTier }, tmobile: { tier, scope, unit, dailyLimit, thresholds, nextTier, usedToday: { date, segments, resetsAt } | null } }`. A null tier/limit means the carrier ladder does not apply (unverified brand, GOVERNMENT entity, PUBLIC_SAFETY_RESTRICTED usecase); a null nextTier means the top rung or a usecase-capped (LOW_VOLUME) campaign.
|
|
428
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ campaignId, brandId, usecase, brand: { status, brandScore, entityType }, att: { tier, scope, unit, sms: { limit }, mms: { limit }, marginPercent, nextTier }, tmobile: { tier, scope, unit, dailyLimit, thresholds, nextTier, usedToday: { date, segments, resetsAt } | null, sharedWith: [{ brandId, brandName }] } }`. A null tier/limit means the carrier ladder does not apply (unverified brand, GOVERNMENT entity, PUBLIC_SAFETY_RESTRICTED usecase); a null nextTier means the top rung or a usecase-capped (LOW_VOLUME) campaign. T-Mobile's counter is keyed per brand EIN, not per brand: sharedWith lists other verified brands in the same group that share this EIN and also carry a T-Mobile limit, since usedToday is their combined total.
|
|
429
429
|
*/
|
|
430
430
|
async getCampaignThroughputLimits({ campaignId, options = {} }) {
|
|
431
431
|
this.client._require({ campaignId });
|
|
@@ -441,7 +441,7 @@ export class Campaigns {
|
|
|
441
441
|
* @param {string} params.groupId - Group identifier
|
|
442
442
|
* @param {RequestOptions} [params.options] - Additional request options
|
|
443
443
|
* @throws {Error} Throws an error if the groupId parameter is missing
|
|
444
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `[{ campaignId, brandId, brandName, usecase, tmobile: { tier, dailyLimit, usedToday: { date, segments, resetsAt } } }]`. Campaigns without a T-Mobile limit (unverified brand, GOVERNMENT entity, PUBLIC_SAFETY_RESTRICTED usecase) are left out. The counter is per brand EIN and UTC day, so every campaign of a brand shows the same usage; a LOW_VOLUME campaign's limit is 2,000 whatever the brand's score.
|
|
444
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `[{ campaignId, brandId, brandName, usecase, tmobile: { tier, dailyLimit, usedToday: { date, segments, resetsAt }, sharedWith: [{ brandId, brandName }] } }]`. Campaigns without a T-Mobile limit (unverified brand, GOVERNMENT entity, PUBLIC_SAFETY_RESTRICTED usecase) are left out. The counter is per brand EIN and UTC day, so every campaign of a brand shows the same usage; a LOW_VOLUME campaign's limit is 2,000 whatever the brand's score. sharedWith lists this brand's other group brands on the same EIN that also carry a T-Mobile limit, since usedToday is their combined total.
|
|
445
445
|
*/
|
|
446
446
|
async getGroupThroughputUsage({ groupId, options = {} }) {
|
|
447
447
|
this.client._require({ groupId });
|
package/src/domains/Messages.js
CHANGED
|
@@ -20,6 +20,20 @@ export class Messages {
|
|
|
20
20
|
this.client = client;
|
|
21
21
|
this.multipartClient = multipartClient;
|
|
22
22
|
this.enableAdmin = enableAdmin;
|
|
23
|
+
|
|
24
|
+
if (enableAdmin) {
|
|
25
|
+
this.admin = {
|
|
26
|
+
/**
|
|
27
|
+
* Read RCS webhook health: how late provider reports reach Signal House, and which tenants' webhooks are failing (signalhouse only)
|
|
28
|
+
* @async
|
|
29
|
+
* @roles signalhouse
|
|
30
|
+
* @param {Object} [params] - The parameters for the read
|
|
31
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
32
|
+
* @returns {Promise<SdkResponse<{ windowMinutes: number, lag: { reports: number, p50Seconds: number|null, p95Seconds: number|null, maxSeconds: number|null }, tenantFailures: Array<{ groupId: string, failures: number, alerted: boolean }> }>>} A promise that resolves to the view
|
|
33
|
+
*/
|
|
34
|
+
getRcsWebhookHealth: async ({ options = {} } = {}) => this.client("/message/rcs/webhook-health", { method: "GET", ...options }),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
/**
|
|
@@ -128,13 +142,28 @@ export class Messages {
|
|
|
128
142
|
* @param {string} params.id - The message ID
|
|
129
143
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
130
144
|
* @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
|
|
145
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the message; an unknown ID is a 404. An RCS message and its fallback leg also carry `costBreakdown`: `{ legs: [{ messageId, channel, billed, billingClass, segments, baseMicros, carrierMicros, rated }] }`, null when it cannot be computed. A settled RCS message also carries `carrierFeeMicros`: the carrier pass-through and media surcharge it was charged
|
|
132
146
|
*/
|
|
133
147
|
async getMessage({ id, options = {} }) {
|
|
134
148
|
this.client._require({ id });
|
|
135
149
|
return this.client(`/message/${encodeURIComponent(id)}`, { method: "GET", ...options });
|
|
136
150
|
}
|
|
137
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Get the taps on one RCS message, oldest first
|
|
154
|
+
* @async
|
|
155
|
+
* @roles api, admin, developer, billing, user
|
|
156
|
+
* @param {Object} params - The parameters for getting the taps
|
|
157
|
+
* @param {string} params.id - The message ID
|
|
158
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
159
|
+
* @throws {Error} Throws an error if the id parameter is missing
|
|
160
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to `{ results: [{ actionType, buttonId, label, postbackData, occurredAt, ratedCostMicros }] }`; an unknown ID is a 404
|
|
161
|
+
*/
|
|
162
|
+
async getMessageInteractions({ id, options = {} }) {
|
|
163
|
+
this.client._require({ id });
|
|
164
|
+
return this.client(`/message/${encodeURIComponent(id)}/interactions`, { method: "GET", ...options });
|
|
165
|
+
}
|
|
166
|
+
|
|
138
167
|
/**
|
|
139
168
|
* Fetch the latest upstream carrier delivery report for a set of messages by ID.
|
|
140
169
|
* Useful for reconciling messages stuck in a non-terminal state. Outbound SMS and MMS messages sent from numbers on
|
|
@@ -398,6 +427,28 @@ export class Messages {
|
|
|
398
427
|
return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
|
|
399
428
|
}
|
|
400
429
|
|
|
430
|
+
/**
|
|
431
|
+
* Export the group's consent ledger, newest first: one append-only record per opt-out or opt-in a recipient gave (a STOP
|
|
432
|
+
* or START keyword, or the confirmation of an opt-out link). It records only; sends do not read it.
|
|
433
|
+
* @async
|
|
434
|
+
* @roles api, admin, developer, billing, user
|
|
435
|
+
* @param {Object} params - The parameters for exporting consent records
|
|
436
|
+
* @param {string} params.groupId - The group whose records to read
|
|
437
|
+
* @param {string} [params.recipientPhoneNumber] - One handset, in any spelling; matched on its digits
|
|
438
|
+
* @param {string} [params.startDate] - Earliest occurredAt, ISO-8601; a bare date is its whole UTC day, a timestamp is bound as sent
|
|
439
|
+
* @param {string} [params.endDate] - Latest occurredAt, ISO-8601; a bare date is its whole UTC day, a timestamp is bound as sent
|
|
440
|
+
* @param {number} [params.page] - Page number (default 1)
|
|
441
|
+
* @param {number} [params.limit] - Records per page (default 100, max 500)
|
|
442
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
443
|
+
* @returns {Promise<SdkResponse<any>>} - `{ data, total, page, limit }`. Each record carries groupId, subgroupId, recipientPhoneNumber (the handset),
|
|
444
|
+
* phoneNumber (the business number or RCS agent id that received it), scope `{ type: CAMPAIGN|AGENT|SUBGROUP, id }`,
|
|
445
|
+
* clearedScopes (for OPT_IN, every `{ type, id }` the START cleared; empty for OPT_OUT), action (OPT_OUT or OPT_IN), source (KEYWORD or LINK), keyword, messageType (SMS, MMS or RCS), messageId, actor `{ type: "RECIPIENT" }`, occurredAt and createdAt.
|
|
446
|
+
*/
|
|
447
|
+
async getConsentRecords({ groupId, recipientPhoneNumber, startDate, endDate, page, limit, options = {} }) {
|
|
448
|
+
const queryString = this.client._getQueryString({ groupId, recipientPhoneNumber, startDate, endDate, page, limit });
|
|
449
|
+
return this.client(`/message/dnc/consent-records${queryString}`, { method: "GET", ...options });
|
|
450
|
+
}
|
|
451
|
+
|
|
401
452
|
/**
|
|
402
453
|
* Send an SMS message to one or more recipient phone numbers
|
|
403
454
|
*
|
package/src/domains/Numbers.js
CHANGED
|
@@ -317,7 +317,8 @@ export class Numbers {
|
|
|
317
317
|
* @param {string} params.phoneNumber - The phone number (E.164, leading + optional)
|
|
318
318
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
319
319
|
* @throws {Error} Throws an error if the phoneNumber parameter is missing
|
|
320
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ phoneNumber, cnam, autoApply, eligible, ineligibleReason }
|
|
320
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ phoneNumber, cnam, autoApply, eligible, ineligibleReason }`;
|
|
321
|
+
* `cnam.source` is MANUAL (set on the number), BRAND (the brand's caller name) or AUTO (subgroup auto-apply)
|
|
321
322
|
*/
|
|
322
323
|
async getCallerName({ phoneNumber, options = {} }) {
|
|
323
324
|
this.client._require({ phoneNumber });
|
|
@@ -347,8 +348,8 @@ export class Numbers {
|
|
|
347
348
|
}
|
|
348
349
|
|
|
349
350
|
/**
|
|
350
|
-
* Remove a phone number's own caller name (CNAM).
|
|
351
|
-
*
|
|
351
|
+
* Remove a phone number's own caller name (CNAM). The number goes back to its brand's caller name if the brand
|
|
352
|
+
* has one (see brands.setCallerName), else to the automatic name if its subgroup has caller name auto-apply on.
|
|
352
353
|
* @async
|
|
353
354
|
* @roles api, admin, developer
|
|
354
355
|
* @param {Object} params - The parameters for the request
|
package/src/domains/Rcs.js
CHANGED
|
@@ -47,6 +47,16 @@
|
|
|
47
47
|
* @property {string} [mobile] - Mobile number, E.164
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Where one prefilled field's value came from. The agent's `autofill` holds one per field, keyed by its path
|
|
52
|
+
* (`consent.optInDetails`); the API marks a field `edited` once its value changes.
|
|
53
|
+
* @typedef {Object} RcsAgentAutofillMarker
|
|
54
|
+
* @property {("brand"|"campaign"|"landing")} source - The record the value came from
|
|
55
|
+
* @property {string|null} [sourceId] - That record's id (brand ID, campaign ID or landing page ID)
|
|
56
|
+
* @property {string} [at] - When the field was filled (ISO 8601; default now)
|
|
57
|
+
* @property {boolean} [edited] - Whether the value changed since (default false)
|
|
58
|
+
*/
|
|
59
|
+
|
|
50
60
|
/**
|
|
51
61
|
* One recipient of an RCS send.
|
|
52
62
|
* @typedef {Object} RcsRecipient
|
|
@@ -107,18 +117,19 @@ export class RcsAgents {
|
|
|
107
117
|
* @param {RcsAgentConsent} [params.consent] - The launch text; required in full before the launch request
|
|
108
118
|
* @param {RcsAgentContact} [params.contact] - The launch contact; required in full before the launch request
|
|
109
119
|
* @param {("OTP"|"TRANSACTIONAL"|"PROMOTIONAL"|"MULTI_USE")} [params.useCase] - The agent's use case; required before submit
|
|
110
|
-
* @param {("NON_CONVERSATIONAL"|"CONVERSATIONAL")} [params.billingCategory] - Default NON_CONVERSATIONAL;
|
|
120
|
+
* @param {("NON_CONVERSATIONAL"|"CONVERSATIONAL")} [params.billingCategory] - Default NON_CONVERSATIONAL (per message); CONVERSATIONAL is billed per interactive session
|
|
111
121
|
* @param {{ mode?: string, channel?: string, from?: string }|null} [params.defaultFallback] - Fallback mode (auto, rcs_only, sms_only, none), channel (auto, sms, mms) and from, a number on the linked campaign
|
|
112
122
|
* @param {string[]} [params.excludedCarriers] - [] or ["T_MOBILE"] (the carrier partner's carrier name)
|
|
113
123
|
* @param {string[]} [params.testers] - Tester numbers (up to 200), invited once the agent exists at the carrier
|
|
124
|
+
* @param {Object<string, RcsAgentAutofillMarker>} [params.autofill] - Where the fields you prefilled came from, by path (`consent.optInDetails`); the API adds its own for what it fills
|
|
114
125
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
115
126
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent (status DRAFT)
|
|
116
127
|
*/
|
|
117
|
-
async create({ brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, options = {} }) {
|
|
128
|
+
async create({ brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill, options = {} }) {
|
|
118
129
|
this.client._require({ brandId });
|
|
119
130
|
return this.client("/rcs/agent", {
|
|
120
131
|
method: "POST",
|
|
121
|
-
body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers },
|
|
132
|
+
body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill },
|
|
122
133
|
...options,
|
|
123
134
|
});
|
|
124
135
|
}
|
|
@@ -130,7 +141,7 @@ export class RcsAgents {
|
|
|
130
141
|
* @param {Object} [params] - Filters
|
|
131
142
|
* @param {string} [params.groupId] - Filter by group ID
|
|
132
143
|
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
133
|
-
* @param {string|string[]} [params.status] - DRAFT, PENDING_REVIEW, REJECTED, AGENT_CREATING or ARCHIVED, one or a list
|
|
144
|
+
* @param {string|string[]} [params.status] - DRAFT, PENDING_REVIEW, REJECTED, AGENT_CREATING, ARCHIVE_PENDING or ARCHIVED, one or a list
|
|
134
145
|
* @param {string} [params.brandId] - Agents linked to this brand (carrier brand ID, provisional UUID or _id)
|
|
135
146
|
* @param {string} [params.campaignId] - Agents linked to this campaign (campaign ID or _id)
|
|
136
147
|
* @param {number} [params.page] - Page number (default 1)
|
|
@@ -150,7 +161,7 @@ export class RcsAgents {
|
|
|
150
161
|
* @param {Object} params - The lookup
|
|
151
162
|
* @param {string} params.agentId - The agent ID (e.g. RCSA7K2M1QZ8RP)
|
|
152
163
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
153
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent
|
|
164
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent; googleAgentId is Google's id for it, null until Google has created the agent
|
|
154
165
|
*/
|
|
155
166
|
async get({ agentId, options = {} }) {
|
|
156
167
|
this.client._require({ agentId });
|
|
@@ -159,9 +170,11 @@ export class RcsAgents {
|
|
|
159
170
|
|
|
160
171
|
/**
|
|
161
172
|
* Edit an agent while it may change: a draft, a Signal House rejection, a request for changes, or an agent in
|
|
162
|
-
* testing (the change is pushed to the carrier partner).
|
|
163
|
-
*
|
|
164
|
-
*
|
|
173
|
+
* testing (the change is pushed to the carrier partner). After a carrier rejected a launch other carriers took
|
|
174
|
+
* (PARTIALLY_LAUNCHED with a REJECTED carrier), only `consent` and `contact` may change, and nothing is pushed: send
|
|
175
|
+
* them with requestCarrierUpdate. `agent`, `consent` and `contact` merge field by field; every other key replaces;
|
|
176
|
+
* campaignId: null unlinks the campaign. 409 in any other status; brandId is locked once the agent exists at the
|
|
177
|
+
* partner and billingCategory once a launch was requested.
|
|
165
178
|
* @async
|
|
166
179
|
* @roles api, admin, developer, billing, user
|
|
167
180
|
* @param {Object} params - The edit
|
|
@@ -176,22 +189,25 @@ export class RcsAgents {
|
|
|
176
189
|
* @param {Object|null} [params.defaultFallback] - The fallback
|
|
177
190
|
* @param {string[]} [params.excludedCarriers] - [] or ["T_MOBILE"] (the carrier partner's carrier name)
|
|
178
191
|
* @param {string[]} [params.testers] - Tester numbers
|
|
192
|
+
* @param {Object<string, RcsAgentAutofillMarker>} [params.autofill] - Replaces the prefill markers; omitted, the stored ones are kept and a changed field's marker turns edited
|
|
179
193
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
180
194
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent
|
|
181
195
|
*/
|
|
182
|
-
async update({ agentId, brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, options = {} }) {
|
|
196
|
+
async update({ agentId, brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill, options = {} }) {
|
|
183
197
|
this.client._require({ agentId });
|
|
184
198
|
return this.client(`/rcs/agent/${encodeURIComponent(agentId)}`, {
|
|
185
199
|
method: "PUT",
|
|
186
|
-
body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers },
|
|
200
|
+
body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill },
|
|
187
201
|
...options,
|
|
188
202
|
});
|
|
189
203
|
}
|
|
190
204
|
|
|
191
205
|
/**
|
|
192
206
|
* Check an agent against the next gate on its path without writing: before it exists at the carrier partner, what
|
|
193
|
-
* creating it needs (the full profile, useCase,
|
|
207
|
+
* creating it needs (the full profile, useCase, a billingCategory); after that, what the launch request needs
|
|
194
208
|
* (a VERIFIED brand, the campaign, the full consent with the video, the contact)
|
|
209
|
+
* The launch gate also runs the carriers' copy rules; each error carries the carrier partner's key as `code`, for
|
|
210
|
+
* example OPT_IN_MSG_RATE_DISCL_MISSING.
|
|
195
211
|
* @async
|
|
196
212
|
* @roles api, admin, developer, billing, user
|
|
197
213
|
* @param {Object} params - The lookup
|
|
@@ -206,8 +222,10 @@ export class RcsAgents {
|
|
|
206
222
|
|
|
207
223
|
/**
|
|
208
224
|
* Submit a draft: create the agent at the carrier partner, with no review first. It needs the full profile, a
|
|
209
|
-
* useCase and
|
|
225
|
+
* useCase and a billingCategory; otherwise a 400 whose details carry { code: "REGISTRATION_INCOMPLETE",
|
|
210
226
|
* errors, warnings }. The agent moves to AGENT_CREATING, then IN_TESTING once the partner reports it ready.
|
|
227
|
+
* A group that has not finished account verification gets a 403 with code GROUP_UNVERIFIED, and a rejected one a 403
|
|
228
|
+
* with code GROUP_REJECTED; a pending verification passes.
|
|
211
229
|
* @async
|
|
212
230
|
* @roles api, admin, developer, billing, user
|
|
213
231
|
* @param {Object} params - The submission
|
|
@@ -224,34 +242,75 @@ export class RcsAgents {
|
|
|
224
242
|
* Request the agent's launch: the launch requirements are checked and the agent goes to Signal House review (status
|
|
225
243
|
* PENDING_REVIEW), whose approval files the launch with the carrier partner. Allowed from IN_TESTING, REJECTED and
|
|
226
244
|
* CARRIER_REJECTED (409 otherwise); a failed requirement is a 400 whose details carry { code:
|
|
227
|
-
* "REGISTRATION_INCOMPLETE", errors, warnings }
|
|
228
|
-
*
|
|
245
|
+
* "REGISTRATION_INCOMPLETE", errors, warnings }, and a copy-rule error carries the carrier partner's key as its `code`
|
|
246
|
+
* (for example OPT_IN_MSG_RATE_DISCL_MISSING). A group that has not finished account verification gets a 403 with code
|
|
247
|
+
* GROUP_UNVERIFIED, and a rejected one a 403 with code GROUP_REJECTED. Sends POST /registration/:agentId/launch: the agent is a registration.
|
|
248
|
+
* The request charges the agent's launch fees: a wallet that cannot cover them gets a 402, and the agent stays where it is. When any fee is due the request must set acknowledgeFees: true, or it gets a 400 with code FEE_ACKNOWLEDGEMENT_REQUIRED and nothing is held; a launch with nothing due needs no acknowledgement. The agent's launchFees quotes what the next request charges.
|
|
249
|
+
* When the agent's brand vertical is healthcare or insurance, the launch needs the protected health information (PHI) disclosure acknowledged: send acknowledgePhi: true, or the request gets a 400 REGISTRATION_INCOMPLETE whose errors name consent.phiAcknowledgement. The API records the acknowledgement as consent.phiAcknowledgement { acknowledgedAt, acknowledgedBy } from the caller; the client sends only the boolean, and an agent update cannot set it. Once recorded, a later launch request needs no new acknowledgement.
|
|
229
250
|
* @async
|
|
230
251
|
* @roles api, admin, developer, billing, user
|
|
231
252
|
* @param {Object} params - The launch request
|
|
232
253
|
* @param {string} params.agentId - The agent ID
|
|
254
|
+
* @param {boolean} [params.acknowledgeFees] - Accept the fees due; required when any are
|
|
255
|
+
* @param {boolean} [params.acknowledgePhi] - Accept the PHI disclosure; required for a healthcare or insurance brand
|
|
233
256
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
234
257
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent (status PENDING_REVIEW)
|
|
235
258
|
*/
|
|
236
|
-
async launch({ agentId, options = {} }) {
|
|
259
|
+
async launch({ agentId, acknowledgeFees, acknowledgePhi, options = {} }) {
|
|
260
|
+
this.client._require({ agentId });
|
|
261
|
+
return this.client(`/registration/${encodeURIComponent(agentId)}/launch`, { method: "POST", body: { acknowledgeFees, acknowledgePhi }, ...options });
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Send Signal House the corrected launch answers after a carrier rejected a launch other carriers took. The carrier
|
|
266
|
+
* partner takes no change through its API once a carrier launched, so Signal House emails it the update; edit
|
|
267
|
+
* `consent` and `contact` first. The agent's carrierUpdate reads REQUESTED for the rejected carriers, then SENT once
|
|
268
|
+
* Signal House sent it. 409 when no carrier is REJECTED after a partial launch, or an update already waits.
|
|
269
|
+
* Sends POST /registration/:agentId/carrier-update: the agent is a registration.
|
|
270
|
+
* @async
|
|
271
|
+
* @roles api, admin, developer, billing, user
|
|
272
|
+
* @param {Object} params - The request
|
|
273
|
+
* @param {string} params.agentId - The agent ID
|
|
274
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
275
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent's registration, with data.carrierUpdate
|
|
276
|
+
*/
|
|
277
|
+
async requestCarrierUpdate({ agentId, options = {} }) {
|
|
237
278
|
this.client._require({ agentId });
|
|
238
|
-
return this.client(`/registration/${encodeURIComponent(agentId)}/
|
|
279
|
+
return this.client(`/registration/${encodeURIComponent(agentId)}/carrier-update`, { method: "POST", ...options });
|
|
239
280
|
}
|
|
240
281
|
|
|
241
282
|
/**
|
|
242
|
-
* Archive an agent
|
|
283
|
+
* Archive an agent. One the carrier partner created stops sending at once and stays ARCHIVE_PENDING until Signal House confirms the partner cancelled it, then ARCHIVED. Archiving cannot be undone; an agent already ARCHIVE_PENDING answers 409.
|
|
243
284
|
* @async
|
|
244
285
|
* @roles api, admin, developer, user
|
|
245
286
|
* @param {Object} params - The archive request
|
|
246
287
|
* @param {string} params.agentId - The agent ID
|
|
247
288
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
248
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent (status ARCHIVED)
|
|
289
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent (status ARCHIVE_PENDING or ARCHIVED)
|
|
249
290
|
*/
|
|
250
291
|
async archive({ agentId, options = {} }) {
|
|
251
292
|
this.client._require({ agentId });
|
|
252
293
|
return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/archive`, { method: "POST", ...options });
|
|
253
294
|
}
|
|
254
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Make the links that start a chat with the agent: an sms: deep link in Google's format, and a short link that redirects to it,
|
|
298
|
+
* to print as a QR code. With the agent's defaultFallback.from, the deep link names that number, so a handset that cannot reach
|
|
299
|
+
* the agent texts it instead. The same request returns the same short link. The links work for approved testers until a carrier
|
|
300
|
+
* launches the agent; before Google has created the agent the request answers 409 with code GOOGLE_AGENT_PENDING.
|
|
301
|
+
* @async
|
|
302
|
+
* @roles api, admin, developer, billing, user
|
|
303
|
+
* @param {Object} params - The request
|
|
304
|
+
* @param {string} params.agentId - The agent ID
|
|
305
|
+
* @param {string} [params.body] - The message the chat opens with, prefilled on the handset (max 1,000 characters)
|
|
306
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
307
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { googleAgentId, deepLink, shortLink }
|
|
308
|
+
*/
|
|
309
|
+
async createEntryPoints({ agentId, body, options = {} }) {
|
|
310
|
+
this.client._require({ agentId });
|
|
311
|
+
return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/entry-points`, { method: "POST", body: { body }, ...options });
|
|
312
|
+
}
|
|
313
|
+
|
|
255
314
|
/**
|
|
256
315
|
* Resend a tester's expired invitation, which starts a new 24 hours for the tester to accept it. The number must be
|
|
257
316
|
* a tester on the agent (404) and its invitation must be EXPIRED (409); up to 20 invitations go out a day (429).
|
|
@@ -268,6 +327,22 @@ export class RcsAgents {
|
|
|
268
327
|
return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/testers/${encodeURIComponent(phoneNumber)}/resend`, { method: "POST", ...options });
|
|
269
328
|
}
|
|
270
329
|
|
|
330
|
+
/**
|
|
331
|
+
* Remove a tester at once, at any point before the agent is archived. The number must be a tester on the agent (404);
|
|
332
|
+
* an archived agent answers 409.
|
|
333
|
+
* @async
|
|
334
|
+
* @roles api, admin, developer, billing, user
|
|
335
|
+
* @param {Object} params - The removal
|
|
336
|
+
* @param {string} params.agentId - The agent ID
|
|
337
|
+
* @param {string} params.phoneNumber - The tester's US number, with or without the +
|
|
338
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
339
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent
|
|
340
|
+
*/
|
|
341
|
+
async removeTester({ agentId, phoneNumber, options = {} }) {
|
|
342
|
+
this.client._require({ agentId, phoneNumber });
|
|
343
|
+
return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/testers/${encodeURIComponent(phoneNumber)}`, { method: "DELETE", ...options });
|
|
344
|
+
}
|
|
345
|
+
|
|
271
346
|
/**
|
|
272
347
|
* Host the agent's logo (224 × 224 px, 50 KB max) or hero image (1440 × 448 px, 200 KB max), PNG or JPEG, and set
|
|
273
348
|
* it on the draft. Images of any other size are refused.
|
|
@@ -326,7 +401,7 @@ export class RcsMessages {
|
|
|
326
401
|
* @param {boolean} [params.isTest] - Send as a test; approved testers only
|
|
327
402
|
* @param {("not_capable"|"ttl_expired"|"delivered"|"read")} [params.simulate] - Simulate this outcome; approved testers only
|
|
328
403
|
* @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
|
|
404
|
+
* @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. A recipient from 19999990000 to 19999990359 makes the whole request a simulation, as on SMS: it resolves to { simulated: true, webhooks } and nothing is stored, sent or charged
|
|
330
405
|
*/
|
|
331
406
|
async send({ agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate, options = {} }) {
|
|
332
407
|
this.client._require({ agentId, recipients });
|
|
@@ -337,6 +412,42 @@ export class RcsMessages {
|
|
|
337
412
|
});
|
|
338
413
|
}
|
|
339
414
|
|
|
415
|
+
/**
|
|
416
|
+
* Send an RCS message to up to 10,000 recipients in the background. The request runs the send's request checks, splits the
|
|
417
|
+
* recipients into chunks of 100, queues each chunk and answers 202. Every message carries the shared bulkId; track progress with
|
|
418
|
+
* the messages list filtered by bulkId (GET /message?bulkId=) and per-message webhooks. A chunk the wallet cannot cover, or that is
|
|
419
|
+
* refused after acceptance, gets BLOCKED messages with blockReason INSUFFICIENT_FUNDS or SEND_REFUSED; a chunk that keeps failing
|
|
420
|
+
* gets SEND_FAILED. Pass options.idempotencyKey to make a retry safe (same bulkId, no duplicate sends); a retry without one may
|
|
421
|
+
* send duplicates.
|
|
422
|
+
* @async
|
|
423
|
+
* @roles api, admin, developer, billing, user
|
|
424
|
+
* @param {Object} params - The send; the same fields as send
|
|
425
|
+
* @param {string} params.agentId - The agent that sends (RCSA…)
|
|
426
|
+
* @param {RcsRecipient[]} params.recipients - Up to 10,000 recipients
|
|
427
|
+
* @param {string} [params.templateId] - A template to send; exactly one of templateId or content
|
|
428
|
+
* @param {number} [params.templateVersion] - A published version of templateId; needs templateId. Pinned when the batch is accepted
|
|
429
|
+
* @param {Object} [params.content] - Inline content; exactly one of templateId or content
|
|
430
|
+
* @param {string} [params.contentFormat] - content.v1 (default) or google.rcs
|
|
431
|
+
* @param {("AUTHENTICATION"|"TRANSACTION"|"SERVICEREQUEST"|"ACKNOWLEDGEMENT"|"PROMOTION")} [params.trafficType] - Required on a MULTI_USE agent when the template sets none
|
|
432
|
+
* @param {number} [params.ttlSeconds] - Seconds each RCS message may wait for delivery, from when its chunk is sent; at most one of ttlSeconds or expireTime
|
|
433
|
+
* @param {string} [params.expireTime] - ISO-8601 time the RCS messages expire
|
|
434
|
+
* @param {RcsMessageFallback} [params.fallback] - The fallback for this send
|
|
435
|
+
* @param {string} [params.statusCallbackUrl] - URL that receives each message's events
|
|
436
|
+
* @param {boolean} [params.enableShortlink] - Shorten the links in the message
|
|
437
|
+
* @param {boolean} [params.isTest] - Send as a test; approved testers only
|
|
438
|
+
* @param {("not_capable"|"ttl_expired"|"delivered"|"read")} [params.simulate] - Simulate this outcome; approved testers only
|
|
439
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
440
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { bulkId, status: "ACCEPTED", recipientCount } (202). Every message of the batch carries bulkId. A recipient from 19999990000 to 19999990359 makes the whole request a simulation, as on send
|
|
441
|
+
*/
|
|
442
|
+
async sendBatch({ agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate, options = {} }) {
|
|
443
|
+
this.client._require({ agentId, recipients });
|
|
444
|
+
return this.client("/message/rcs/batch", {
|
|
445
|
+
method: "POST",
|
|
446
|
+
body: { agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate },
|
|
447
|
+
...options,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
340
451
|
/**
|
|
341
452
|
* Check a send without writing anything. Takes the same parameters as send.
|
|
342
453
|
* @async
|
|
@@ -385,7 +496,7 @@ export class RcsMessages {
|
|
|
385
496
|
* @param {string} [params.expireTime] - ISO-8601 time the RCS message expires
|
|
386
497
|
* @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
498
|
* @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
|
|
499
|
+
* @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 for one recipient, and rcsLeg.cost already holds it for every recipient; rcsLeg.cost is null with the fallback mode sms_only; a message over 100 MB adds a MEDIA_TOO_LARGE issue.
|
|
389
500
|
*/
|
|
390
501
|
async estimate({ agentId, recipients, recipientCount, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, options = {} }) {
|
|
391
502
|
this.client._require({ agentId });
|
|
@@ -404,13 +515,36 @@ export class RcsMessages {
|
|
|
404
515
|
* @param {string} params.agentId - The agent (RCSA…)
|
|
405
516
|
* @param {string[]} params.phoneNumbers - Up to 500 numbers, 10-15 digits, with or without the +
|
|
406
517
|
* @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
|
|
518
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { results: [{ phoneNumber, capability, rcsEnabled, reason, features, carrier, checkedAt, cached }] }, capability being ENABLED, UNREACHABLE or UNKNOWN, and reason CAPABLE, NOT_CAPABLE, NOT_LAUNCHED_ON_CARRIER or UNKNOWN; rcsEnabled is true only for CAPABLE, carrier and checkedAt may be null, and features is empty today
|
|
408
519
|
*/
|
|
409
520
|
async capabilities({ agentId, phoneNumbers, options = {} }) {
|
|
410
521
|
this.client._require({ agentId, phoneNumbers });
|
|
411
522
|
return this.client("/rcs/capabilities", { method: "POST", body: { agentId, phoneNumbers }, ...options });
|
|
412
523
|
}
|
|
413
524
|
|
|
525
|
+
/**
|
|
526
|
+
* Fake an inbound event from an approved tester of the agent, with no carrier involved: it runs the real inbound handlers and webhooks, as free test traffic. A simulated STOP really opts the tester out; a simulated START clears it. Anyone else gets a 403 with code NOT_TESTER. Returns 202 with { status, messageId }.
|
|
527
|
+
* @async
|
|
528
|
+
* @roles api, admin, developer, billing, user
|
|
529
|
+
* @param {Object} params - The event
|
|
530
|
+
* @param {string} params.agentId - The agent (RCSA…)
|
|
531
|
+
* @param {string} params.from - The approved tester's number
|
|
532
|
+
* @param {string} params.type - TEXT, SUGGESTION, LOCATION, FILE or UNSUBSCRIBE
|
|
533
|
+
* @param {string} [params.text] - The text; required for TEXT
|
|
534
|
+
* @param {string} [params.postbackData] - The tapped suggestion's postback; SUGGESTION needs this or buttonId
|
|
535
|
+
* @param {string} [params.messageId] - The message a tap answers; the latest message delivered to the tester by default
|
|
536
|
+
* @param {string} [params.buttonId] - The suggestion's position, as webhooks report it
|
|
537
|
+
* @param {number} [params.latitude] - Required for LOCATION
|
|
538
|
+
* @param {number} [params.longitude] - Required for LOCATION
|
|
539
|
+
* @param {string} [params.fileName] - The file's name, for FILE
|
|
540
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
541
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { status: "QUEUED", messageId }
|
|
542
|
+
*/
|
|
543
|
+
async simulateInbound({ agentId, from, type, text, postbackData, messageId, buttonId, latitude, longitude, fileName, options = {} }) {
|
|
544
|
+
this.client._require({ agentId, from, type });
|
|
545
|
+
return this.client("/message/rcs/simulate-inbound", { method: "POST", body: { agentId, from, type, text, postbackData, messageId, buttonId, latitude, longitude, fileName }, ...options });
|
|
546
|
+
}
|
|
547
|
+
|
|
414
548
|
/**
|
|
415
549
|
* Get one message by its ID. The same route as messages.getMessage.
|
|
416
550
|
* @async
|
|
@@ -418,7 +552,7 @@ export class RcsMessages {
|
|
|
418
552
|
* @param {Object} params - The lookup
|
|
419
553
|
* @param {string} params.messageId - The message ID
|
|
420
554
|
* @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
|
|
555
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the message; an unknown ID is a 404. A settled RCS message carries carrierFeeMicros, the carrier pass-through and media surcharge it was charged
|
|
422
556
|
*/
|
|
423
557
|
async get({ messageId, options = {} }) {
|
|
424
558
|
this.client._require({ messageId });
|
|
@@ -446,11 +580,11 @@ export class RcsMessages {
|
|
|
446
580
|
* @param {string} [params.deliveredChannel] - Filter by the channel that delivered the message (rcs, sms, mms)
|
|
447
581
|
* @param {boolean} [params.isTest] - true for test messages only, false to leave them out
|
|
448
582
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
449
|
-
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of messages
|
|
583
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of messages; a settled RCS message carries carrierFeeMicros
|
|
450
584
|
*/
|
|
451
585
|
async list({ groupId, from, to, agentId, status, page, limit, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest, options = {} }) {
|
|
452
586
|
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" });
|
|
587
|
+
const queryString = this.client._getQueryString({ registrationId: agentId, startDate: from, endDate: to, groupId, status, page, limit, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest, messageType: "RCS", dateBounds: "exact" });
|
|
454
588
|
return this.client(`/message${queryString}`, { method: "GET", ...options });
|
|
455
589
|
}
|
|
456
590
|
}
|