@signalhousellc/sdk 1.0.69 → 1.1.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 +2 -0
- package/src/domains/Agents.js +131 -0
- package/src/domains/Brands.js +56 -3
- package/src/domains/Messages.js +67 -28
- package/src/domains/Numbers.js +3 -2
- package/src/domains/Registrations.js +240 -0
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -28,6 +28,7 @@ import { Groups } from "./domains/Groups.js";
|
|
|
28
28
|
import { Landings } from "./domains/Landings.js";
|
|
29
29
|
import { Messages } from "./domains/Messages.js";
|
|
30
30
|
import { Numbers } from "./domains/Numbers.js";
|
|
31
|
+
import { Registrations } from "./domains/Registrations.js";
|
|
31
32
|
import { Onboarding } from "./domains/Onboarding.js";
|
|
32
33
|
import { Dnc } from "./domains/Dnc.js";
|
|
33
34
|
import { Shortlinks } from "./domains/Shortlinks.js";
|
|
@@ -73,6 +74,7 @@ export class SignalHouseSDK {
|
|
|
73
74
|
this.landings = new Landings(client, multipartClient, this.enableAdmin);
|
|
74
75
|
this.messages = new Messages(client, multipartClient, this.enableAdmin);
|
|
75
76
|
this.numbers = new Numbers(client, multipartClient, this.enableAdmin);
|
|
77
|
+
this.registrations = new Registrations(client, this.enableAdmin);
|
|
76
78
|
this.onboarding = new Onboarding(client, this.enableAdmin);
|
|
77
79
|
this.dnc = new Dnc(client, this.enableAdmin);
|
|
78
80
|
this.shortlinks = new Shortlinks(client, this.enableAdmin);
|
package/src/domains/Agents.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
14
14
|
* @property {string} [greeting] - Opening line the agent leads with.
|
|
15
15
|
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
16
|
+
* @property {string} [sendAuthority] - Default send authority: "review" or "autopilot" (defaults to "review"). Deployments may override it per subgroup.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -22,6 +23,48 @@
|
|
|
22
23
|
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
23
24
|
* @property {string} [greeting] - Opening line the agent leads with.
|
|
24
25
|
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
26
|
+
* @property {string} [sendAuthority] - Default send authority: "review" or "autopilot". Deployments may override it per subgroup.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An agent profile as returned by the server. `publishStatus` and `publishedAt` are read-only:
|
|
31
|
+
* they change only through `publishAgentProfile` and `unpublishAgentProfile`.
|
|
32
|
+
* @typedef {Object} AgentProfile
|
|
33
|
+
* @property {string} agentProfileId - The agent profile id.
|
|
34
|
+
* @property {string} groupId - The owning group id.
|
|
35
|
+
* @property {string|null} subgroupId - The owning subgroup id; null for a group-level agent.
|
|
36
|
+
* @property {string} name - The agent's name.
|
|
37
|
+
* @property {string} status - Lifecycle status: "active" or "inactive".
|
|
38
|
+
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
39
|
+
* @property {string} [greeting] - Opening line the agent leads with.
|
|
40
|
+
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
41
|
+
* @property {string} sendAuthority - Default send authority: "review" or "autopilot".
|
|
42
|
+
* @property {string} publishStatus - "draft" or "published" (read-only).
|
|
43
|
+
* @property {string|null} publishedAt - When the profile was last published; null while never published (read-only).
|
|
44
|
+
* @property {string} createdAt - Creation timestamp.
|
|
45
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The fields of a deployment of a group-level agent to a subgroup.
|
|
50
|
+
* @typedef {Object} AgentDeploymentData
|
|
51
|
+
* @property {string|null} [sendAuthorityOverride] - "review" or "autopilot" to override the profile's default for this subgroup; null clears the override so the deployment inherits the profile default.
|
|
52
|
+
* @property {boolean} [enabled] - Whether this deployment is live (defaults to true).
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A deployment of a group-level agent to a subgroup, as returned by the server.
|
|
57
|
+
* @typedef {Object} AgentDeployment
|
|
58
|
+
* @property {string} agentDeploymentId - The deployment id.
|
|
59
|
+
* @property {string} groupId - The group that owns the agent and the subgroup.
|
|
60
|
+
* @property {string} subgroupId - The subgroup the agent is deployed to.
|
|
61
|
+
* @property {string} agentProfileId - The deployed agent.
|
|
62
|
+
* @property {string|null} sendAuthorityOverride - "review", "autopilot", or null (inherit the profile default).
|
|
63
|
+
* @property {string|null} sendAuthorityChangedBy - userId of whoever last changed the override.
|
|
64
|
+
* @property {string|null} sendAuthorityChangedAt - When the override last changed.
|
|
65
|
+
* @property {boolean} enabled - Whether this deployment is live.
|
|
66
|
+
* @property {string} createdAt - Creation timestamp.
|
|
67
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
25
68
|
*/
|
|
26
69
|
|
|
27
70
|
/**
|
|
@@ -361,6 +404,94 @@ export class Agents {
|
|
|
361
404
|
return this.client(`/agent/profiles/${safeId}/channels/${safeChannel}`, { method: "DELETE", ...options });
|
|
362
405
|
}
|
|
363
406
|
|
|
407
|
+
/**
|
|
408
|
+
* List a group-level agent's deployments to subgroups.
|
|
409
|
+
* @async
|
|
410
|
+
* @roles api, admin, developer, billing, user
|
|
411
|
+
* @param {Object} params - The parameters for listing deployments.
|
|
412
|
+
* @param {string} params.agentProfileId - The agent whose deployments to list.
|
|
413
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
414
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
415
|
+
* @returns {Promise<SdkResponse<AgentDeployment[]>>} - The agent's deployments returned from the server.
|
|
416
|
+
*/
|
|
417
|
+
async getAgentDeployments({ agentProfileId, options = {} }) {
|
|
418
|
+
this.client._require({ agentProfileId });
|
|
419
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
420
|
+
return this.client(`/agent/profiles/${safeId}/deployments`, { method: "GET", ...options });
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Deploy a group-level agent to a subgroup, or change that deployment (upsert). One row per
|
|
425
|
+
* (agent, subgroup); the subgroup is taken from the path, the fields from deploymentData.
|
|
426
|
+
* @async
|
|
427
|
+
* @roles api, admin, developer
|
|
428
|
+
* @param {Object} params - The parameters for the upsert.
|
|
429
|
+
* @param {string} params.agentProfileId - The agent to deploy.
|
|
430
|
+
* @param {string} params.subgroupId - The subgroup to deploy to (at least 8 characters, starts with 'S').
|
|
431
|
+
* @param {AgentDeploymentData} [params.deploymentData] - The fields to set.
|
|
432
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
433
|
+
* @throws {Error} Throws an error if agentProfileId or subgroupId is missing.
|
|
434
|
+
* @returns {Promise<SdkResponse<AgentDeployment>>} - The created or updated deployment returned from the server.
|
|
435
|
+
*/
|
|
436
|
+
async upsertAgentDeployment({ agentProfileId, subgroupId, deploymentData = {}, options = {} }) {
|
|
437
|
+
this.client._require({ agentProfileId, subgroupId });
|
|
438
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
439
|
+
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
440
|
+
return this.client(`/agent/profiles/${safeId}/deployments/${safeSubgroupId}`, { method: "PUT", body: deploymentData, ...options });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Remove an agent's deployment from a subgroup.
|
|
445
|
+
* @async
|
|
446
|
+
* @roles api, admin, developer
|
|
447
|
+
* @param {Object} params - The parameters for the delete.
|
|
448
|
+
* @param {string} params.agentProfileId - The deployed agent.
|
|
449
|
+
* @param {string} params.subgroupId - The subgroup to remove the deployment from.
|
|
450
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
451
|
+
* @throws {Error} Throws an error if agentProfileId or subgroupId is missing.
|
|
452
|
+
* @returns {Promise<SdkResponse<AgentDeployment>>} - The removed deployment returned from the server.
|
|
453
|
+
*/
|
|
454
|
+
async deleteAgentDeployment({ agentProfileId, subgroupId, options = {} }) {
|
|
455
|
+
this.client._require({ agentProfileId, subgroupId });
|
|
456
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
457
|
+
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
458
|
+
return this.client(`/agent/profiles/${safeId}/deployments/${safeSubgroupId}`, { method: "DELETE", ...options });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Publish an agent profile, setting its `publishStatus` to "published" and stamping
|
|
463
|
+
* `publishedAt`. The server rejects the call with 400 when the agent has no enabled
|
|
464
|
+
* deployment, and with 409 when the agent is inactive.
|
|
465
|
+
* @async
|
|
466
|
+
* @roles api, admin, developer
|
|
467
|
+
* @param {Object} params - The parameters for publishing.
|
|
468
|
+
* @param {string} params.agentProfileId - The agent profile to publish.
|
|
469
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
470
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
471
|
+
* @returns {Promise<SdkResponse<AgentProfile>>} - The published agent profile returned from the server.
|
|
472
|
+
*/
|
|
473
|
+
async publishAgentProfile({ agentProfileId, options = {} }) {
|
|
474
|
+
this.client._require({ agentProfileId });
|
|
475
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
476
|
+
return this.client(`/agent/profiles/${safeId}/publish`, { method: "POST", ...options });
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Return an agent profile to draft, setting its `publishStatus` to "draft".
|
|
481
|
+
* @async
|
|
482
|
+
* @roles api, admin, developer
|
|
483
|
+
* @param {Object} params - The parameters for unpublishing.
|
|
484
|
+
* @param {string} params.agentProfileId - The agent profile to unpublish.
|
|
485
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
486
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
487
|
+
* @returns {Promise<SdkResponse<AgentProfile>>} - The unpublished agent profile returned from the server.
|
|
488
|
+
*/
|
|
489
|
+
async unpublishAgentProfile({ agentProfileId, options = {} }) {
|
|
490
|
+
this.client._require({ agentProfileId });
|
|
491
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
492
|
+
return this.client(`/agent/profiles/${safeId}/unpublish`, { method: "POST", ...options });
|
|
493
|
+
}
|
|
494
|
+
|
|
364
495
|
/**
|
|
365
496
|
* Read the tenant AI settings for a scope (group, or a subgroup within it) — brand, tone,
|
|
366
497
|
* timezone, business hours, and after-hours message. Returns the scope's own row only (no
|
package/src/domains/Brands.js
CHANGED
|
@@ -140,11 +140,64 @@ export class Brands {
|
|
|
140
140
|
* @param {number} [params.limit] - The number of items per page
|
|
141
141
|
* @param {string} [params.status] - The status of the brand to filter by (PENDING_CREATION, PENDING_APPROVAL, UNVERIFIED, VERIFIED, VETTED_VERIFIED, PENDING_DELETE, DELETED)
|
|
142
142
|
* @param {string} [params.registrationType] - Filter by registration type ("TEN_DLC", "TOLL_FREE", or "SHORT_CODE")
|
|
143
|
+
* @param {string} [params.search] - Staff-only (no id/subgroupId/groupId): case-insensitive substring over brandId, names, EIN, email, group, subgroup and reference ID
|
|
144
|
+
* @param {string} [params.sortBy] - Staff-only: createdAt, brandId, displayName, groupId, subgroupId, status, entityType or country
|
|
145
|
+
* @param {"asc"|"desc"} [params.sortOrder] - Staff-only: sort direction (default asc)
|
|
146
|
+
* @param {string} [params.entityType] - Staff-only: exact entity type filter
|
|
147
|
+
* @param {string} [params.ein] - Staff-only: EIN substring filter
|
|
148
|
+
* @param {string} [params.email] - Staff-only: support email substring filter
|
|
149
|
+
* @param {string} [params.referenceId] - Staff-only: reference ID substring filter
|
|
150
|
+
* @param {string|Array<string>} [params.groupIds] - Staff-only: restrict to these group IDs (sent comma-separated)
|
|
151
|
+
* @param {string} [params.createdFrom] - Staff-only: inclusive createdAt lower bound (ISO date)
|
|
152
|
+
* @param {string} [params.createdTo] - Staff-only: inclusive createdAt upper bound (ISO date)
|
|
153
|
+
* @param {boolean} [params.excludeDeleted] - Staff-only: hide DELETED brands when no status is given
|
|
154
|
+
* @param {boolean} [params.includeTotal] - Staff-only: with page and limit, return `{ data, total, page, limit, totalPages }` instead of the array
|
|
143
155
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
144
|
-
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, [key: string]: any }
|
|
156
|
+
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, [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. 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.
|
|
145
157
|
*/
|
|
146
|
-
async getBrands({
|
|
147
|
-
|
|
158
|
+
async getBrands({
|
|
159
|
+
id,
|
|
160
|
+
subgroupId,
|
|
161
|
+
groupId,
|
|
162
|
+
page,
|
|
163
|
+
limit,
|
|
164
|
+
status,
|
|
165
|
+
registrationType,
|
|
166
|
+
search,
|
|
167
|
+
sortBy,
|
|
168
|
+
sortOrder,
|
|
169
|
+
entityType,
|
|
170
|
+
ein,
|
|
171
|
+
email,
|
|
172
|
+
referenceId,
|
|
173
|
+
groupIds,
|
|
174
|
+
createdFrom,
|
|
175
|
+
createdTo,
|
|
176
|
+
excludeDeleted,
|
|
177
|
+
includeTotal,
|
|
178
|
+
options = {},
|
|
179
|
+
}) {
|
|
180
|
+
const filters = {
|
|
181
|
+
id,
|
|
182
|
+
subgroupId,
|
|
183
|
+
groupId,
|
|
184
|
+
page,
|
|
185
|
+
limit,
|
|
186
|
+
status,
|
|
187
|
+
registrationType,
|
|
188
|
+
search,
|
|
189
|
+
sortBy,
|
|
190
|
+
sortOrder,
|
|
191
|
+
entityType,
|
|
192
|
+
ein,
|
|
193
|
+
email,
|
|
194
|
+
referenceId,
|
|
195
|
+
groupIds: Array.isArray(groupIds) ? (groupIds.length ? groupIds.join(',') : undefined) : groupIds,
|
|
196
|
+
createdFrom,
|
|
197
|
+
createdTo,
|
|
198
|
+
excludeDeleted,
|
|
199
|
+
includeTotal,
|
|
200
|
+
};
|
|
148
201
|
const queryString = this.client._getQueryString(filters);
|
|
149
202
|
return this.client(`/brand${queryString}`, { method: 'GET', ...options });
|
|
150
203
|
}
|
package/src/domains/Messages.js
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Serialise regionScopes for the query string: an array of branches becomes JSON, a string is passed through.
|
|
9
|
+
* @param {Object} filters - Query filters that may carry regionScopes
|
|
10
|
+
* @returns {Object} - The filters with regionScopes JSON-encoded when present
|
|
11
|
+
*/
|
|
12
|
+
function withRegionScopes(filters) {
|
|
13
|
+
if (filters.regionScopes === undefined) return filters;
|
|
14
|
+
const regionScopes = typeof filters.regionScopes === "string" ? filters.regionScopes : JSON.stringify(filters.regionScopes);
|
|
15
|
+
return { ...filters, regionScopes };
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export class Messages {
|
|
8
19
|
constructor(client, multipartClient, enableAdmin) {
|
|
9
20
|
this.client = client;
|
|
@@ -12,10 +23,12 @@ export class Messages {
|
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
/**
|
|
15
|
-
* Estimate
|
|
16
|
-
* recipients, and is unavailable unless Canada is enabled for the environment.
|
|
26
|
+
* Estimate regional SMS/MMS retail cost; no charge or send. A Canadian sender requires a Ready Canadian sender and
|
|
27
|
+
* Canadian or US recipients, and is unavailable unless Canada is enabled for the environment. A +44 (UK) sender
|
|
28
|
+
* estimates SMS to GB mobiles only and returns region "GB"; while UK sending is disabled for the environment a UK
|
|
29
|
+
* sender is refused with a 400.
|
|
17
30
|
* @async
|
|
18
|
-
* @param {Object} params - Sender, up to 100 recipients, messageBody and request options.
|
|
31
|
+
* @param {Object} params - Sender, up to 100 recipients (10-15 digits each), messageBody and request options.
|
|
19
32
|
* @returns {Promise<SdkResponse<any>>} - Per-recipient rates and total in microdollars; unknown carriers use the upper fallback.
|
|
20
33
|
*/
|
|
21
34
|
async estimateMessage({ senderPhoneNumber, recipientPhoneNumbers, messageBody, messageType = "SMS", options = {} }) {
|
|
@@ -32,10 +45,13 @@ export class Messages {
|
|
|
32
45
|
* @param {string} [params.brandId] - Filter messages by the ID of the associated brand
|
|
33
46
|
* @param {string} [params.subgroupId] - Filter messages by the ID of the associated subgroup
|
|
34
47
|
* @param {string} [params.groupId] - Filter messages by the ID of the associated group
|
|
48
|
+
* @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.
|
|
35
49
|
* @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED)
|
|
36
50
|
* @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
|
|
37
51
|
* @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.
|
|
38
52
|
* @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).
|
|
53
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Accepted whether or not the environment serves hourly analytics.
|
|
54
|
+
* @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. Accepted whether or not the environment serves hourly analytics.
|
|
39
55
|
* @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.
|
|
40
56
|
* @param {string} [params.carrier] - Filter messages by the carrier used for sending
|
|
41
57
|
* @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.
|
|
@@ -61,6 +77,7 @@ export class Messages {
|
|
|
61
77
|
brandId,
|
|
62
78
|
subgroupId,
|
|
63
79
|
groupId,
|
|
80
|
+
registrationId,
|
|
64
81
|
phoneNumber,
|
|
65
82
|
senderPhoneNumber,
|
|
66
83
|
recipientPhoneNumber,
|
|
@@ -68,6 +85,8 @@ export class Messages {
|
|
|
68
85
|
direction,
|
|
69
86
|
messageType,
|
|
70
87
|
channel,
|
|
88
|
+
region,
|
|
89
|
+
regionScopes,
|
|
71
90
|
matchAny,
|
|
72
91
|
carrier,
|
|
73
92
|
sentimentLabel,
|
|
@@ -81,8 +100,8 @@ export class Messages {
|
|
|
81
100
|
dateBounds,
|
|
82
101
|
options = {},
|
|
83
102
|
}) {
|
|
84
|
-
const filters = { id, campaignId, brandId, subgroupId, groupId, phoneNumber, senderPhoneNumber, recipientPhoneNumber, status, direction, messageType, channel, matchAny, carrier, sentimentLabel, errorCode, startDate, endDate, sortField, sortOrder, page, limit, dateBounds };
|
|
85
|
-
const queryString = this.client._getQueryString(filters);
|
|
103
|
+
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 };
|
|
104
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
86
105
|
return this.client(`/message${queryString}`, { method: "GET", ...options });
|
|
87
106
|
}
|
|
88
107
|
|
|
@@ -115,6 +134,7 @@ export class Messages {
|
|
|
115
134
|
* @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.
|
|
116
135
|
* @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.
|
|
117
136
|
* @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.
|
|
137
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
118
138
|
* @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.
|
|
119
139
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
120
140
|
* @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). Accepts a single value, an array, or a comma-separated string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -123,6 +143,8 @@ export class Messages {
|
|
|
123
143
|
* @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.
|
|
124
144
|
* @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.
|
|
125
145
|
* @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).
|
|
146
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
147
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
126
148
|
* @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".
|
|
127
149
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
128
150
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the analytics data. Also includes inbound-message
|
|
@@ -134,9 +156,9 @@ export class Messages {
|
|
|
134
156
|
* summed or re-averaged across types, rows or responses. To weight a subset of message types, pass
|
|
135
157
|
* messageType and read sentimentScore.
|
|
136
158
|
*/
|
|
137
|
-
async getAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, matchAny, dateBounds, options = {} }) {
|
|
138
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, matchAny, dateBounds };
|
|
139
|
-
const queryString = this.client._getQueryString(filters);
|
|
159
|
+
async getAnalytics({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, matchAny, dateBounds, options = {} }) {
|
|
160
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, matchAny, dateBounds };
|
|
161
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
140
162
|
return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
|
|
141
163
|
}
|
|
142
164
|
|
|
@@ -149,6 +171,7 @@ export class Messages {
|
|
|
149
171
|
* @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.
|
|
150
172
|
* @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.
|
|
151
173
|
* @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.
|
|
174
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
152
175
|
* @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.
|
|
153
176
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
154
177
|
* @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). Accepts a single value, an array, or a comma-separated string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -156,6 +179,8 @@ export class Messages {
|
|
|
156
179
|
* @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.
|
|
157
180
|
* @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.
|
|
158
181
|
* @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.
|
|
182
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
183
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
159
184
|
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value, including "day", is rejected with a 400 -- omit the parameter unless hour grain is wanted.
|
|
160
185
|
* @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, 10DLC only) and caps the span at 31 days. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
161
186
|
* @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".
|
|
@@ -168,9 +193,9 @@ export class Messages {
|
|
|
168
193
|
* score is divided server-side and the raw sums are never returned: a score is an average and must never be
|
|
169
194
|
* summed or re-averaged across types, rows or responses.
|
|
170
195
|
*/
|
|
171
|
-
async getAnalyticsDetail({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, granularity, breakdown, dateBounds, options = {} }) {
|
|
172
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, granularity, breakdown, dateBounds };
|
|
173
|
-
const queryString = this.client._getQueryString(filters);
|
|
196
|
+
async getAnalyticsDetail({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, granularity, breakdown, dateBounds, options = {} }) {
|
|
197
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, granularity, breakdown, dateBounds };
|
|
198
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
174
199
|
return this.client(`/message/analytics/detail${queryString}`, { method: "GET", ...options });
|
|
175
200
|
}
|
|
176
201
|
|
|
@@ -186,6 +211,7 @@ export class Messages {
|
|
|
186
211
|
* @param {string} params.groupId - The group to scope the read to (required)
|
|
187
212
|
* @param {string|string[]} [params.brandId] - Brand scope. Accepts a single value, an array, or a comma-separated string.
|
|
188
213
|
* @param {string|string[]} [params.campaignId] - Campaign scope; wins over brandId. Accepts a single value, an array, or a comma-separated string.
|
|
214
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). Accepts a single value or an array.
|
|
189
215
|
* @param {string|string[]} [params.carrierFamily] - Carrier-family filter (ATT, TMobile, Verizon, USCellular, ...). Accepts a single value, an array, or a comma-separated string.
|
|
190
216
|
* @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).
|
|
191
217
|
* @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).
|
|
@@ -195,8 +221,8 @@ export class Messages {
|
|
|
195
221
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
196
222
|
* @returns {Promise<SdkResponse<any>>} - `{ totals, byDate, byCarrierFamily, byBreakdown: { dimension: "carrierFamily", rows } }`. Every row carries segments, messages, peakSegmentsPerMinute, peakMessagesPerMinute, peakMinute (UTC "YYYY-MM-DD HH:MM:SS", null when no traffic), sendingMinutes, averageSegmentsPerSendingMinute and minutesAtCeiling.
|
|
197
223
|
*/
|
|
198
|
-
async getAnalyticsThroughput({ groupId, brandId, campaignId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds, options = {} }) {
|
|
199
|
-
const filters = { groupId, brandId, campaignId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds };
|
|
224
|
+
async getAnalyticsThroughput({ groupId, brandId, campaignId, registrationId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds, options = {} }) {
|
|
225
|
+
const filters = { groupId, brandId, campaignId, registrationId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds };
|
|
200
226
|
const queryString = this.client._getQueryString(filters);
|
|
201
227
|
return this.client(`/message/analytics/throughput${queryString}`, { method: "GET", ...options });
|
|
202
228
|
}
|
|
@@ -208,11 +234,12 @@ export class Messages {
|
|
|
208
234
|
* @roles api, admin, developer, billing, user
|
|
209
235
|
* @param {Object} params - The parameters for getting analytics filter options
|
|
210
236
|
* @param {string} params.groupId - The ID of the group whose filter options to load
|
|
237
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
211
238
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
212
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers }
|
|
239
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers }. 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.
|
|
213
240
|
*/
|
|
214
|
-
async getAnalyticsFilterOptions({ groupId, options = {} }) {
|
|
215
|
-
const filters = { groupId };
|
|
241
|
+
async getAnalyticsFilterOptions({ groupId, region, options = {} }) {
|
|
242
|
+
const filters = { groupId, region };
|
|
216
243
|
const queryString = this.client._getQueryString(filters);
|
|
217
244
|
return this.client(`/message/analytics/filter-options${queryString}`, { method: "GET", ...options });
|
|
218
245
|
}
|
|
@@ -227,6 +254,7 @@ export class Messages {
|
|
|
227
254
|
* @param {string|string[]} [params.subgroupId]
|
|
228
255
|
* @param {string|string[]} [params.brandId]
|
|
229
256
|
* @param {string|string[]} [params.campaignId]
|
|
257
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
230
258
|
* @param {string|string[]} [params.phoneNumber]
|
|
231
259
|
* @param {string|string[]} [params.carrier]
|
|
232
260
|
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless); single value, array, or comma-separated. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -237,13 +265,15 @@ export class Messages {
|
|
|
237
265
|
* @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).
|
|
238
266
|
* @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.
|
|
239
267
|
* @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".
|
|
268
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
269
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
240
270
|
* @param {RequestOptions} [params.options]
|
|
241
271
|
* @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).
|
|
242
272
|
* 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.
|
|
243
273
|
*/
|
|
244
|
-
async getAnalyticsBySubgroup({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, messageType, dateBounds, options = {} }) {
|
|
245
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, messageType, dateBounds };
|
|
246
|
-
const queryString = this.client._getQueryString(filters);
|
|
274
|
+
async getAnalyticsBySubgroup({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, messageType, dateBounds, options = {} }) {
|
|
275
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, messageType, dateBounds };
|
|
276
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
247
277
|
return this.client(`/message/analytics/by-subgroup${queryString}`, { method: "GET", ...options });
|
|
248
278
|
}
|
|
249
279
|
|
|
@@ -257,6 +287,7 @@ export class Messages {
|
|
|
257
287
|
* @param {string|string[]} [params.subgroupId]
|
|
258
288
|
* @param {string|string[]} [params.brandId]
|
|
259
289
|
* @param {string|string[]} [params.campaignId]
|
|
290
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
260
291
|
* @param {string|string[]} [params.phoneNumber]
|
|
261
292
|
* @param {string|string[]} [params.carrier]
|
|
262
293
|
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless); single value, array, or comma-separated. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -266,12 +297,14 @@ export class Messages {
|
|
|
266
297
|
* @param {number} [params.limit=50] - max 50 per page
|
|
267
298
|
* @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.
|
|
268
299
|
* @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".
|
|
300
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
301
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
269
302
|
* @param {RequestOptions} [params.options]
|
|
270
303
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, totalErrors: { sms, mms, p2p, all }, page, limit }
|
|
271
304
|
*/
|
|
272
|
-
async getAnalyticsByErrorCode({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, dateBounds, options = {} }) {
|
|
273
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, dateBounds };
|
|
274
|
-
const queryString = this.client._getQueryString(filters);
|
|
305
|
+
async getAnalyticsByErrorCode({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
306
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, dateBounds };
|
|
307
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
275
308
|
return this.client(`/message/analytics/by-error-code${queryString}`, { method: "GET", ...options });
|
|
276
309
|
}
|
|
277
310
|
|
|
@@ -284,18 +317,21 @@ export class Messages {
|
|
|
284
317
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
285
318
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
286
319
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
320
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
287
321
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
288
322
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
289
323
|
* @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
|
|
290
324
|
* @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
|
|
291
325
|
* @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.
|
|
292
326
|
* @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".
|
|
327
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
328
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
293
329
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
294
330
|
* @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.
|
|
295
331
|
*/
|
|
296
|
-
async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, channel, dateBounds, options = {} }) {
|
|
297
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, channel, dateBounds };
|
|
298
|
-
const queryString = this.client._getQueryString(filters);
|
|
332
|
+
async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
333
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, channel, region, regionScopes, dateBounds };
|
|
334
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
299
335
|
return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
|
|
300
336
|
}
|
|
301
337
|
|
|
@@ -308,6 +344,7 @@ export class Messages {
|
|
|
308
344
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
309
345
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
310
346
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
347
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
311
348
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
312
349
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
313
350
|
* @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
|
|
@@ -318,12 +355,14 @@ export class Messages {
|
|
|
318
355
|
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
319
356
|
* @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.
|
|
320
357
|
* @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".
|
|
358
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (UK is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
359
|
+
* @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. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
321
360
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
322
361
|
* @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), copied from the inbound message that triggered the opt-out. campaignId is null on subgroup-scoped records (non-US recipients).
|
|
323
362
|
*/
|
|
324
|
-
async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, dateBounds, options = {} }) {
|
|
325
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, dateBounds };
|
|
326
|
-
const queryString = this.client._getQueryString(filters);
|
|
363
|
+
async getDncRecords({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
364
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, region, regionScopes, dateBounds };
|
|
365
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
327
366
|
return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
|
|
328
367
|
}
|
|
329
368
|
|
package/src/domains/Numbers.js
CHANGED
|
@@ -77,6 +77,7 @@ export class Numbers {
|
|
|
77
77
|
* @param {Object} params - The parameters for filtering the phone numbers
|
|
78
78
|
* @param {string} [params.phoneNumber] - Filter by phone number (partial match)
|
|
79
79
|
* @param {string} [params.campaignId] - Filter by campaign ID
|
|
80
|
+
* @param {string} [params.registrationId] - Filter to numbers provisioned under this registration.
|
|
80
81
|
* @param {string} [params.brandId] - Filter by brand ID
|
|
81
82
|
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
82
83
|
* @param {string} [params.groupId] - Filter by group ID
|
|
@@ -102,8 +103,8 @@ export class Numbers {
|
|
|
102
103
|
* or GET /campaign/health.
|
|
103
104
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of phone numbers
|
|
104
105
|
*/
|
|
105
|
-
async getPhoneNumbers({ phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
106
|
-
const filters = { phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit };
|
|
106
|
+
async getPhoneNumbers({ phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
107
|
+
const filters = { phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, page, limit };
|
|
107
108
|
const queryString = this.client._getQueryString(filters);
|
|
108
109
|
return this.client(`/number${queryString}`, { method: 'GET', ...options });
|
|
109
110
|
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sender registrations for every jurisdiction and type: the catalog of what a region offers, retail quotes,
|
|
9
|
+
* customer submissions and staff review operations. `type` selects the shape of `data`
|
|
10
|
+
* (for VIRTUAL_LONG_CODE: quantity, useCases and the optional voice dossier).
|
|
11
|
+
*/
|
|
12
|
+
export class Registrations {
|
|
13
|
+
constructor(client, enableAdmin) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
this.enableAdmin = enableAdmin;
|
|
16
|
+
|
|
17
|
+
if (enableAdmin) {
|
|
18
|
+
this.admin = {
|
|
19
|
+
/**
|
|
20
|
+
* Approve or reject a registration awaiting Signal House review (signalhouse only)
|
|
21
|
+
* @async
|
|
22
|
+
* @roles signalhouse
|
|
23
|
+
* @param {Object} params - The parameters for the review decision
|
|
24
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
25
|
+
* @param {("APPROVE"|"REJECT")} params.action - The review decision
|
|
26
|
+
* @param {string} [params.reason] - Why the registration was rejected; required when action is REJECT
|
|
27
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
28
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
29
|
+
*/
|
|
30
|
+
reviewRegistration: async ({ registrationId, action, reason, options = {} }) => {
|
|
31
|
+
this.client._require({ registrationId, action });
|
|
32
|
+
const safeId = encodeURIComponent(registrationId);
|
|
33
|
+
return this.client(`/registration/${safeId}/review`, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: { action, reason },
|
|
36
|
+
...options,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Save corrections to the type's correctable fields for a registration the provider sent back for
|
|
42
|
+
* more information; owner, quantity, bundle and provider order never change (signalhouse only)
|
|
43
|
+
* @async
|
|
44
|
+
* @roles signalhouse
|
|
45
|
+
* @param {Object} params - The parameters for the correction
|
|
46
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
47
|
+
* @param {string} params.reason - Why the registration was corrected
|
|
48
|
+
* @param {Object} params.data - The type's correctable fields (for VIRTUAL_LONG_CODE: useCases and, for SMS + Voice, voice)
|
|
49
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
50
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
51
|
+
*/
|
|
52
|
+
correctRegistration: async ({ registrationId, reason, data, options = {} }) => {
|
|
53
|
+
this.client._require({ registrationId, reason, data });
|
|
54
|
+
const safeId = encodeURIComponent(registrationId);
|
|
55
|
+
return this.client(`/registration/${safeId}/corrections`, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: { reason, data },
|
|
58
|
+
...options,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Allocate a provider-owned number to a registration through the staff recovery path (signalhouse only)
|
|
64
|
+
* @async
|
|
65
|
+
* @roles signalhouse
|
|
66
|
+
* @param {Object} params - The parameters for the allocation
|
|
67
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
68
|
+
* @param {string} params.phoneNumber - The E.164 number (10-15 digits, optional leading +) to allocate
|
|
69
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
70
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
71
|
+
*/
|
|
72
|
+
addNumber: async ({ registrationId, phoneNumber, options = {} }) => {
|
|
73
|
+
this.client._require({ registrationId, phoneNumber });
|
|
74
|
+
const safeId = encodeURIComponent(registrationId);
|
|
75
|
+
return this.client(`/registration/${safeId}/numbers`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: { phoneNumber },
|
|
78
|
+
...options,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Link an existing provider order to a registration parked in RECONCILIATION_REQUIRED (signalhouse only)
|
|
84
|
+
* @async
|
|
85
|
+
* @roles signalhouse
|
|
86
|
+
* @param {Object} params - The parameters for the reconciliation
|
|
87
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
88
|
+
* @param {string} params.externalId - The provider's identifier for the existing order
|
|
89
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
90
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
91
|
+
*/
|
|
92
|
+
reconcile: async ({ registrationId, externalId, options = {} }) => {
|
|
93
|
+
this.client._require({ registrationId, externalId });
|
|
94
|
+
const safeId = encodeURIComponent(registrationId);
|
|
95
|
+
return this.client(`/registration/${safeId}/reconcile`, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
body: { externalId },
|
|
98
|
+
...options,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Download the completed carrier application as DOCX bytes (signalhouse only)
|
|
104
|
+
* @async
|
|
105
|
+
* @roles signalhouse
|
|
106
|
+
* @param {Object} params - The parameters for the download
|
|
107
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
108
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
109
|
+
* @returns {Promise<SdkResponse<ArrayBuffer>>} A promise that resolves to the DOCX document as an ArrayBuffer
|
|
110
|
+
*/
|
|
111
|
+
getApplication: async ({ registrationId, options = {} }) => {
|
|
112
|
+
this.client._require({ registrationId });
|
|
113
|
+
const safeId = encodeURIComponent(registrationId);
|
|
114
|
+
return this.client(`/registration/${safeId}/application`, {
|
|
115
|
+
method: "GET",
|
|
116
|
+
responseType: "arraybuffer",
|
|
117
|
+
...options,
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get the registration types a region offers and whether each can be acquired right now
|
|
126
|
+
* @async
|
|
127
|
+
* @roles api, admin, developer, billing, user
|
|
128
|
+
* @param {Object} params - The parameters for the catalog
|
|
129
|
+
* @param {string} params.region - ISO-2 jurisdiction (US, GB or CA; UK is accepted for GB)
|
|
130
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
131
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { region, jurisdiction, sendingRequiresRegistration, registeredThrough, provisioning, types }
|
|
132
|
+
*/
|
|
133
|
+
async getCatalog({ region, options = {} }) {
|
|
134
|
+
this.client._require({ region });
|
|
135
|
+
const queryString = this.client._getQueryString({ region });
|
|
136
|
+
return this.client(`/registration/catalog${queryString}`, { method: "GET", ...options });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get retail quotes for a registration type: one quote per capability bundle with per-number setupAmount
|
|
141
|
+
* and monthlyAmount, the totals for the quantity (integer microdollars) and etaDays.
|
|
142
|
+
* Unavailable (400) while the type cannot be acquired in the region.
|
|
143
|
+
* @async
|
|
144
|
+
* @roles api, admin, developer, billing, user
|
|
145
|
+
* @param {Object} params - The parameters for the quote
|
|
146
|
+
* @param {string} params.region - ISO-2 jurisdiction (UK is accepted for GB)
|
|
147
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE)
|
|
148
|
+
* @param {number} [params.quantity=1] - Number of numbers to quote (1-100)
|
|
149
|
+
* @param {string} [params.groupId] - Group to price for; staff only
|
|
150
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
151
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [quotes] }
|
|
152
|
+
*/
|
|
153
|
+
async getQuotes({ region, type, quantity = 1, groupId, options = {} }) {
|
|
154
|
+
this.client._require({ region, type });
|
|
155
|
+
const queryString = this.client._getQueryString({ region, type, quantity, groupId });
|
|
156
|
+
return this.client(`/registration/quotes${queryString}`, { method: "GET", ...options });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* List registrations for an authorized group; staff may omit groupId to read the review queue
|
|
161
|
+
* @async
|
|
162
|
+
* @roles api, admin, developer, billing, user
|
|
163
|
+
* @param {Object} [params] - The parameters for filtering the registrations
|
|
164
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
165
|
+
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
166
|
+
* @param {string|string[]} [params.region] - Filter by one ISO-2 jurisdiction or a list
|
|
167
|
+
* @param {string} [params.type] - Filter by registration type
|
|
168
|
+
* @param {string} [params.kind] - Filter by kind (identity, program, sender)
|
|
169
|
+
* @param {string|string[]} [params.status] - Filter by one registration status or a list
|
|
170
|
+
* @param {string} [params.parentRegistrationId] - Filter by the parent registration ID
|
|
171
|
+
* @param {string} [params.phoneNumber] - Filter to registrations holding this phone number
|
|
172
|
+
* @param {string} [params.sortBy] - Sort field: createdAt (default), subgroupId, registrationId, region or status
|
|
173
|
+
* @param {string} [params.sortOrder] - Sort direction: asc or desc (default)
|
|
174
|
+
* @param {number} [params.page] - Page number (default 1)
|
|
175
|
+
* @param {number} [params.limit] - Registrations per page (default 25, max 100)
|
|
176
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
177
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [registrations], totalCount, page, limit }
|
|
178
|
+
*/
|
|
179
|
+
async getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit, options = {} } = {}) {
|
|
180
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit });
|
|
181
|
+
return this.client(`/registration${queryString}`, { method: "GET", ...options });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Get a single registration with its review outcome, the type's public data and its status history
|
|
186
|
+
* @async
|
|
187
|
+
* @roles api, admin, developer, billing, user
|
|
188
|
+
* @param {Object} params - The parameters for getting the registration
|
|
189
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
190
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
191
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration
|
|
192
|
+
*/
|
|
193
|
+
async getRegistration({ registrationId, options = {} }) {
|
|
194
|
+
this.client._require({ registrationId });
|
|
195
|
+
const safeId = encodeURIComponent(registrationId);
|
|
196
|
+
return this.client(`/registration/${safeId}`, { method: "GET", ...options });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Cancel a registration. Allowed from SIGNAL_HOUSE_REVIEW, SIGNAL_HOUSE_APPROVED, PENDING_PROVIDER, NEEDS_INFORMATION,
|
|
201
|
+
* PAYMENT_REQUIRED and APPROVED (409 otherwise). Numbers already allocated stay on the account and stop sending.
|
|
202
|
+
* @async
|
|
203
|
+
* @roles api, admin, developer, user
|
|
204
|
+
* @param {Object} params - The parameters for cancelling the registration
|
|
205
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
206
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
207
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the cancelled registration
|
|
208
|
+
*/
|
|
209
|
+
async cancelRegistration({ registrationId, options = {} }) {
|
|
210
|
+
this.client._require({ registrationId });
|
|
211
|
+
const safeId = encodeURIComponent(registrationId);
|
|
212
|
+
return this.client(`/registration/${safeId}`, { method: "DELETE", ...options });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Submit a registration. `type` selects the shape of `data`: for VIRTUAL_LONG_CODE it is { quantity (1-100),
|
|
217
|
+
* useCases (1-10 descriptions), voice? } where voice is required exactly when capabilities include VOICE.
|
|
218
|
+
* Reuse the same clientRequestId only when retrying an identical payload (409 otherwise).
|
|
219
|
+
* Unavailable (400) while the type cannot be acquired in the region.
|
|
220
|
+
* @async
|
|
221
|
+
* @roles api, admin, developer, billing, user
|
|
222
|
+
* @param {Object} params - The parameters for the registration
|
|
223
|
+
* @param {string} params.region - ISO-2 jurisdiction (UK is accepted for GB)
|
|
224
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE)
|
|
225
|
+
* @param {string} params.subgroupId - Subgroup that will own the registration and any allocated numbers
|
|
226
|
+
* @param {string} params.clientRequestId - Idempotency key (UUID)
|
|
227
|
+
* @param {string[]} params.capabilities - One of the type's bundles, e.g. ["SMS"] or ["SMS", "VOICE"]
|
|
228
|
+
* @param {Object} params.data - The type's submission fields
|
|
229
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
230
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the created registration
|
|
231
|
+
*/
|
|
232
|
+
async createRegistration({ region, type, subgroupId, clientRequestId, capabilities, data, options = {} }) {
|
|
233
|
+
this.client._require({ region, type, subgroupId, clientRequestId, capabilities, data });
|
|
234
|
+
return this.client("/registration", {
|
|
235
|
+
method: "POST",
|
|
236
|
+
body: { region, type, subgroupId, clientRequestId, capabilities, data },
|
|
237
|
+
...options,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|