@signalhousellc/sdk 1.1.0 → 1.3.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 +4 -1
- package/src/domains/Agents.js +231 -0
- package/src/domains/Auth.js +9 -2
- package/src/domains/Messages.js +13 -12
- package/src/domains/Onboarding.js +34 -0
- package/src/domains/Registrations.js +19 -13
- package/src/domains/Shortlinks.js +30 -0
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -4,6 +4,7 @@ import axios from "axios";
|
|
|
4
4
|
* @typedef {Object} RequestOptions
|
|
5
5
|
* @property {string} [token] - An optional bearer token to include in the request for authentication
|
|
6
6
|
* @property {object} [headers] - Additional headers to include in the request
|
|
7
|
+
* @property {string} [idempotencyKey] - Sent as the Idempotency-Key header; a retry with the same key and request replays the first response instead of repeating it
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -103,10 +104,12 @@ export class SignalHouseSDK {
|
|
|
103
104
|
const instance = axios.create({ baseURL: this.baseUrl, headers: isMultipart ? {} : { "Content-Type": "application/json" } });
|
|
104
105
|
|
|
105
106
|
// Add a request interceptor to include the API key in the Authorization header
|
|
106
|
-
instance.interceptors.request.use((/** @type {import('axios').InternalAxiosRequestConfig & { token?: string }} */ config) => {
|
|
107
|
+
instance.interceptors.request.use((/** @type {import('axios').InternalAxiosRequestConfig & { token?: string, idempotencyKey?: string }} */ config) => {
|
|
107
108
|
const token = config.token || this.apiKey;
|
|
108
109
|
config.headers.Authorization = `Bearer ${token}`;
|
|
110
|
+
if (config.idempotencyKey) config.headers["Idempotency-Key"] = config.idempotencyKey;
|
|
109
111
|
delete config.token; // Remove token from config to avoid sending it as a header
|
|
112
|
+
delete config.idempotencyKey;
|
|
110
113
|
return config;
|
|
111
114
|
});
|
|
112
115
|
|
package/src/domains/Agents.js
CHANGED
|
@@ -67,6 +67,57 @@
|
|
|
67
67
|
* @property {string} updatedAt - Last-update timestamp.
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The fields of an endpoint binding: which agent answers a number.
|
|
72
|
+
* @typedef {Object} AgentEndpointData
|
|
73
|
+
* @property {string} agentProfileId - The agent that answers the number (required). It must be active, in the number's group, and either belong to the number's subgroup or be a group-level agent with an enabled deployment there.
|
|
74
|
+
* @property {string} [answerMode] - Which inbound messages the agent answers: "all_inbound" (the only mode, and the default).
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* An endpoint binding (which agent answers a number), as returned by the server.
|
|
79
|
+
* @typedef {Object} AgentEndpoint
|
|
80
|
+
* @property {string} agentEndpointId - The binding id ("AEP..." prefix).
|
|
81
|
+
* @property {string} groupId - The group that owns the binding.
|
|
82
|
+
* @property {string|null} subgroupId - The subgroup the number belongs to.
|
|
83
|
+
* @property {string} channel - The channel; "sms" in v1.
|
|
84
|
+
* @property {string} endpointType - The endpoint kind; "sms_number" in v1.
|
|
85
|
+
* @property {string} endpointValue - The phone number: digits only, country code included, no "+".
|
|
86
|
+
* @property {string} agentProfileId - The agent that answers the number.
|
|
87
|
+
* @property {string} answerMode - Which inbound messages the agent answers ("all_inbound").
|
|
88
|
+
* @property {Object|null} overrides - Free-form per-endpoint overrides; null when none.
|
|
89
|
+
* @property {boolean} enabled - Whether the binding is live.
|
|
90
|
+
* @property {string} createdAt - Creation timestamp.
|
|
91
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A reply an SMS agent wrote but did not send, held for a person to approve or reject (the
|
|
96
|
+
* Pending Replies queue), as returned by the server.
|
|
97
|
+
* @typedef {Object} AgentReplyDraft
|
|
98
|
+
* @property {string} agentReplyDraftId - The draft id ("ARD..." prefix).
|
|
99
|
+
* @property {string} groupId - The group that owns the draft.
|
|
100
|
+
* @property {string|null} subgroupId - The subgroup whose number the reply goes out from.
|
|
101
|
+
* @property {string} agentProfileId - The agent that wrote the reply.
|
|
102
|
+
* @property {string|null} conversationId - The conversation the reply belongs to.
|
|
103
|
+
* @property {string} channel - The channel; "sms".
|
|
104
|
+
* @property {string} endpointValue - The agent's number the reply is sent from, digits only.
|
|
105
|
+
* @property {string} contactPhoneNumber - The contact the reply is sent to, digits only.
|
|
106
|
+
* @property {string} inboundText - The contact message the agent was answering.
|
|
107
|
+
* @property {string} draftText - The reply as the agent wrote it.
|
|
108
|
+
* @property {string|null} sentText - The text actually sent; differs from draftText when edited.
|
|
109
|
+
* @property {string} reason - Why it was held: "review_mode", "escalation", "fallback" or "guardrail".
|
|
110
|
+
* @property {string} status - "pending", "sending", "sent", "rejected" or "failed" (the send path accepted nothing, e.g. the contact opted out).
|
|
111
|
+
* @property {string|null} decidedBy - The user who approved or rejected it.
|
|
112
|
+
* @property {string|null} decidedAt - When it was approved or rejected.
|
|
113
|
+
* @property {string|null} sentMessageId - The outbound message id once sent (for an external delivery, the id you reported).
|
|
114
|
+
* @property {string|null} claimId - The current claim's id (set when a decision claims the draft); complete and release must name it.
|
|
115
|
+
* @property {string|null} deliveredBy - Who delivers an approved reply: "signalhouse" (approveAgentReplyDraft) or "external" (claimAgentReplyDraft); null until decided.
|
|
116
|
+
* @property {string|null} failureReason - "delivery_unconfirmed" when an external claim was never completed or released; otherwise null.
|
|
117
|
+
* @property {string} createdAt - Creation timestamp.
|
|
118
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
119
|
+
*/
|
|
120
|
+
|
|
70
121
|
/**
|
|
71
122
|
* The per-channel settings for one agent. Model, voice and sampling settings live here rather
|
|
72
123
|
* than on the profile: each channel is served by a different runtime, and the model catalogues
|
|
@@ -458,6 +509,186 @@ export class Agents {
|
|
|
458
509
|
return this.client(`/agent/profiles/${safeId}/deployments/${safeSubgroupId}`, { method: "DELETE", ...options });
|
|
459
510
|
}
|
|
460
511
|
|
|
512
|
+
/**
|
|
513
|
+
* List the endpoint bindings (which agent answers which number) in a group.
|
|
514
|
+
* @async
|
|
515
|
+
* @roles api, admin, developer, billing, user
|
|
516
|
+
* @param {Object} params - The parameters for listing endpoint bindings.
|
|
517
|
+
* @param {string} params.groupId - The group whose bindings to list (required).
|
|
518
|
+
* @param {string} [params.subgroupId] - Narrow to one subgroup's bindings.
|
|
519
|
+
* @param {string} [params.agentProfileId] - Narrow to one agent's bindings.
|
|
520
|
+
* @param {string} [params.channel] - Narrow to one channel ("sms").
|
|
521
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
522
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
523
|
+
* @returns {Promise<SdkResponse<AgentEndpoint[]>>} - The bindings, ordered by number, returned from the server.
|
|
524
|
+
*/
|
|
525
|
+
async getAgentEndpoints({ groupId, subgroupId, agentProfileId, channel, options = {} }) {
|
|
526
|
+
this.client._require({ groupId });
|
|
527
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, agentProfileId, channel });
|
|
528
|
+
return this.client(`/agent/endpoints${queryString}`, { method: "GET", ...options });
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Assign an agent to answer a number (upsert keyed by channel + number). Assigning again
|
|
533
|
+
* replaces the previous agent, so a number has one agent per channel. v1 binds SMS numbers only.
|
|
534
|
+
* @async
|
|
535
|
+
* @roles api, admin, developer
|
|
536
|
+
* @param {Object} params - The parameters for the upsert.
|
|
537
|
+
* @param {string} params.channel - The channel to bind; must be "sms".
|
|
538
|
+
* @param {string} params.endpointValue - The phone number: 10 to 15 digits, country code included, no "+".
|
|
539
|
+
* @param {AgentEndpointData} params.endpointData - The agent to assign and its answer mode.
|
|
540
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
541
|
+
* @throws {Error} Throws an error if channel, endpointValue, or endpointData.agentProfileId is missing.
|
|
542
|
+
* @returns {Promise<SdkResponse<AgentEndpoint>>} - The created or updated binding returned from the server.
|
|
543
|
+
*/
|
|
544
|
+
async upsertAgentEndpoint({ channel, endpointValue, endpointData, options = {} }) {
|
|
545
|
+
this.client._require({ channel, endpointValue, agentProfileId: endpointData?.agentProfileId });
|
|
546
|
+
const safeChannel = encodeURIComponent(channel);
|
|
547
|
+
const safeEndpointValue = encodeURIComponent(endpointValue);
|
|
548
|
+
return this.client(`/agent/endpoints/${safeChannel}/${safeEndpointValue}`, { method: "PUT", body: endpointData, ...options });
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Remove the agent assigned to a number.
|
|
553
|
+
* @async
|
|
554
|
+
* @roles api, admin, developer
|
|
555
|
+
* @param {Object} params - The parameters for the delete.
|
|
556
|
+
* @param {string} params.channel - The bound channel; must be "sms".
|
|
557
|
+
* @param {string} params.endpointValue - The phone number: digits only, country code included, no "+".
|
|
558
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
559
|
+
* @throws {Error} Throws an error if channel or endpointValue is missing.
|
|
560
|
+
* @returns {Promise<SdkResponse<AgentEndpoint>>} - The removed binding returned from the server.
|
|
561
|
+
*/
|
|
562
|
+
async deleteAgentEndpoint({ channel, endpointValue, options = {} }) {
|
|
563
|
+
this.client._require({ channel, endpointValue });
|
|
564
|
+
const safeChannel = encodeURIComponent(channel);
|
|
565
|
+
const safeEndpointValue = encodeURIComponent(endpointValue);
|
|
566
|
+
return this.client(`/agent/endpoints/${safeChannel}/${safeEndpointValue}`, { method: "DELETE", ...options });
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* List held agent replies (the Pending Replies queue) in a group, newest first.
|
|
571
|
+
* @async
|
|
572
|
+
* @roles api, admin, developer, billing, user
|
|
573
|
+
* @param {Object} params - The parameters for listing drafts.
|
|
574
|
+
* @param {string} params.groupId - The group whose drafts to list (required).
|
|
575
|
+
* @param {string} [params.subgroupId] - Narrow to one subgroup.
|
|
576
|
+
* @param {string} [params.agentProfileId] - Narrow to one agent.
|
|
577
|
+
* @param {string} [params.status] - Narrow to one status, e.g. "pending".
|
|
578
|
+
* @param {number} [params.page] - Page number for pagination.
|
|
579
|
+
* @param {number} [params.limit] - Items per page (default 25, max 500).
|
|
580
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
581
|
+
* @throws {Error} Throws an error if the groupId parameter is missing.
|
|
582
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft[]>>} - The drafts returned from the server.
|
|
583
|
+
*/
|
|
584
|
+
async getAgentReplyDrafts({ groupId, subgroupId, agentProfileId, status, page, limit, options = {} }) {
|
|
585
|
+
this.client._require({ groupId });
|
|
586
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, agentProfileId, status, page, limit });
|
|
587
|
+
return this.client(`/agent/drafts${queryString}`, { method: "GET", ...options });
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Approve a held agent reply and send it from the agent's number, optionally with edited text.
|
|
592
|
+
* It goes through the normal SMS send path, so opt-out and billing apply; the draft comes back
|
|
593
|
+
* "failed" when the send path accepted nothing. A draft that is no longer pending returns 409.
|
|
594
|
+
* @async
|
|
595
|
+
* @roles api, admin, developer, billing, user
|
|
596
|
+
* @param {Object} params - The parameters for the approval.
|
|
597
|
+
* @param {string} params.agentReplyDraftId - The draft to approve.
|
|
598
|
+
* @param {string} [params.text] - Replacement text when a person edited the reply.
|
|
599
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
600
|
+
* @throws {Error} Throws an error if the agentReplyDraftId parameter is missing.
|
|
601
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft>>} - The draft, now sent (or failed), returned from the server.
|
|
602
|
+
*/
|
|
603
|
+
async approveAgentReplyDraft({ agentReplyDraftId, text, options = {} }) {
|
|
604
|
+
this.client._require({ agentReplyDraftId });
|
|
605
|
+
const safeId = encodeURIComponent(agentReplyDraftId);
|
|
606
|
+
const body = text === undefined ? {} : { text };
|
|
607
|
+
return this.client(`/agent/drafts/${safeId}/approve`, { method: "POST", body, ...options });
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Reject a held agent reply so it is never sent. A draft that is no longer pending returns 409.
|
|
612
|
+
* @async
|
|
613
|
+
* @roles api, admin, developer, billing, user
|
|
614
|
+
* @param {Object} params - The parameters for the rejection.
|
|
615
|
+
* @param {string} params.agentReplyDraftId - The draft to reject.
|
|
616
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
617
|
+
* @throws {Error} Throws an error if the agentReplyDraftId parameter is missing.
|
|
618
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft>>} - The rejected draft returned from the server.
|
|
619
|
+
*/
|
|
620
|
+
async rejectAgentReplyDraft({ agentReplyDraftId, options = {} }) {
|
|
621
|
+
this.client._require({ agentReplyDraftId });
|
|
622
|
+
const safeId = encodeURIComponent(agentReplyDraftId);
|
|
623
|
+
return this.client(`/agent/drafts/${safeId}/reject`, { method: "POST", ...options });
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Claim a held agent reply for delivery through your own channel instead of Signal House's send path.
|
|
628
|
+
* Nothing is sent: the draft becomes "sending" with `deliveredBy: "external"`, `sentText` and a new
|
|
629
|
+
* `claimId` set, and you then report the outcome with `completeAgentReplyDraft` or `releaseAgentReplyDraft`,
|
|
630
|
+
* passing that `claimId`. The claim
|
|
631
|
+
* means two approvals can never both deliver. A draft that is no longer pending returns 409; one whose
|
|
632
|
+
* number has left its subgroup returns 400 and is closed as failed.
|
|
633
|
+
* @async
|
|
634
|
+
* @roles api, admin, developer, billing, user
|
|
635
|
+
* @param {Object} params - The parameters for the claim.
|
|
636
|
+
* @param {string} params.agentReplyDraftId - The draft to claim.
|
|
637
|
+
* @param {string} [params.text] - Replacement text when a person edited the reply.
|
|
638
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
639
|
+
* @throws {Error} Throws an error if the agentReplyDraftId parameter is missing.
|
|
640
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft>>} - The claimed draft returned from the server.
|
|
641
|
+
*/
|
|
642
|
+
async claimAgentReplyDraft({ agentReplyDraftId, text, options = {} }) {
|
|
643
|
+
this.client._require({ agentReplyDraftId });
|
|
644
|
+
const safeId = encodeURIComponent(agentReplyDraftId);
|
|
645
|
+
const body = text === undefined ? {} : { text };
|
|
646
|
+
return this.client(`/agent/drafts/${safeId}/claim`, { method: "POST", body, ...options });
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Mark a claimed agent reply sent once your channel accepted it. Only the claim named by `claimId` can be
|
|
651
|
+
* completed (anything else returns 409). It is also accepted after an unfinished claim was closed as
|
|
652
|
+
* "failed" with `failureReason: "delivery_unconfirmed"`, which it turns into "sent".
|
|
653
|
+
* @async
|
|
654
|
+
* @roles api, admin, developer, billing, user
|
|
655
|
+
* @param {Object} params - The parameters for the completion.
|
|
656
|
+
* @param {string} params.agentReplyDraftId - The claimed draft.
|
|
657
|
+
* @param {string} params.claimId - The claim being completed, as returned by `claimAgentReplyDraft`.
|
|
658
|
+
* @param {string} [params.externalMessageId] - Your channel's id for the sent message, stored as `sentMessageId`.
|
|
659
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
660
|
+
* @throws {Error} Throws an error if the agentReplyDraftId or claimId parameter is missing.
|
|
661
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft>>} - The draft, now sent, returned from the server.
|
|
662
|
+
*/
|
|
663
|
+
async completeAgentReplyDraft({ agentReplyDraftId, claimId, externalMessageId, options = {} }) {
|
|
664
|
+
this.client._require({ agentReplyDraftId, claimId });
|
|
665
|
+
const safeId = encodeURIComponent(agentReplyDraftId);
|
|
666
|
+
const body = externalMessageId === undefined ? { claimId } : { claimId, externalMessageId };
|
|
667
|
+
return this.client(`/agent/drafts/${safeId}/complete`, { method: "POST", body, ...options });
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Give back a claim whose reply certainly did not go out: the draft returns to "pending", or with
|
|
672
|
+
* `permanent` is closed as "failed". If you cannot tell whether it went out, do not release it; a claim
|
|
673
|
+
* left unfinished for 30 minutes is closed as failed with `failureReason: "delivery_unconfirmed"`.
|
|
674
|
+
* Only the claim named by `claimId` can be released; anything else returns 409.
|
|
675
|
+
* @async
|
|
676
|
+
* @roles api, admin, developer, billing, user
|
|
677
|
+
* @param {Object} params - The parameters for the release.
|
|
678
|
+
* @param {string} params.agentReplyDraftId - The claimed draft.
|
|
679
|
+
* @param {string} params.claimId - The claim being released, as returned by `claimAgentReplyDraft`.
|
|
680
|
+
* @param {boolean} [params.permanent] - True closes the draft as failed instead of returning it to pending.
|
|
681
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
682
|
+
* @throws {Error} Throws an error if the agentReplyDraftId or claimId parameter is missing.
|
|
683
|
+
* @returns {Promise<SdkResponse<AgentReplyDraft>>} - The draft, pending again or failed, returned from the server.
|
|
684
|
+
*/
|
|
685
|
+
async releaseAgentReplyDraft({ agentReplyDraftId, claimId, permanent, options = {} }) {
|
|
686
|
+
this.client._require({ agentReplyDraftId, claimId });
|
|
687
|
+
const safeId = encodeURIComponent(agentReplyDraftId);
|
|
688
|
+
const body = permanent === undefined ? { claimId } : { claimId, permanent };
|
|
689
|
+
return this.client(`/agent/drafts/${safeId}/release`, { method: "POST", body, ...options });
|
|
690
|
+
}
|
|
691
|
+
|
|
461
692
|
/**
|
|
462
693
|
* Publish an agent profile, setting its `publishStatus` to "published" and stamping
|
|
463
694
|
* `publishedAt`. The server rejects the call with 400 when the agent has no enabled
|
package/src/domains/Auth.js
CHANGED
|
@@ -63,13 +63,20 @@ export class Auth {
|
|
|
63
63
|
* @param {boolean} [params.acceptedTermsOfService] - Whether the user accepted the Terms of Service
|
|
64
64
|
* @param {string} [params.psXid] - PartnerStack click id (ps_xid) captured from a referral link
|
|
65
65
|
* @param {string} [params.psPartnerKey] - PartnerStack partner key (ps_partner_key) captured from a referral link
|
|
66
|
+
* @param {Object} [params.attribution] - Marketing attribution captured at signup
|
|
67
|
+
* @param {string} [params.attribution.posthogDistinctId] - PostHog distinct id of the registering visitor
|
|
68
|
+
* @param {Object} [params.attribution.firstTouch] - First-ever visit: utmSource, utmMedium, utmCampaign, utmTerm, utmContent, gclid, gbraid, wbraid, fbclid, msclkid, referrer, landingUrl, timestamp
|
|
69
|
+
* @param {Object} [params.attribution.lastTouch] - Visit that registered, same keys as firstTouch
|
|
70
|
+
* @param {string} [params.attribution.shLanding] - Marketing-site landing page passed on the register link (sh_landing)
|
|
71
|
+
* @param {string} [params.attribution.shCta] - Marketing-site CTA that sent the visitor (sh_cta)
|
|
72
|
+
* @param {string} [params.attribution.shGuide] - Marketing-site guide the CTA was on (sh_guide)
|
|
66
73
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
67
74
|
* @returns {Promise<SdkResponse<any>>} The response from the server (contains the JWT token)
|
|
68
75
|
*/
|
|
69
|
-
async register({ businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, options = {} }) {
|
|
76
|
+
async register({ businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution, options = {} }) {
|
|
70
77
|
return this.client(`/auth/register`, {
|
|
71
78
|
method: "POST",
|
|
72
|
-
body: { businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey },
|
|
79
|
+
body: { businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution },
|
|
73
80
|
...options,
|
|
74
81
|
});
|
|
75
82
|
}
|
package/src/domains/Messages.js
CHANGED
|
@@ -26,7 +26,8 @@ export class Messages {
|
|
|
26
26
|
* Estimate regional SMS/MMS retail cost; no charge or send. A Canadian sender requires a Ready Canadian sender and
|
|
27
27
|
* Canadian or US recipients, and is unavailable unless Canada is enabled for the environment. A +44 (UK) sender
|
|
28
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.
|
|
29
|
+
* sender is refused with a 400. The sender may also be a READY alphanumeric sender ID (e.g. "ACME"; UK recipients,
|
|
30
|
+
* SMS only); its estimate counts the "\nOpt out: sihou.io/o/{code}" footer the server appends to every such message.
|
|
30
31
|
* @async
|
|
31
32
|
* @param {Object} params - Sender, up to 100 recipients (10-15 digits each), messageBody and request options.
|
|
32
33
|
* @returns {Promise<SdkResponse<any>>} - Per-recipient rates and total in microdollars; unknown carriers use the upper fallback.
|
|
@@ -50,15 +51,15 @@ export class Messages {
|
|
|
50
51
|
* @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
|
|
51
52
|
* @param {string|string[]} [params.messageType] - Filter messages by their type. Accepts a single value or an array (e.g. ["SMS", "MMS"]). Allowed values: SMS, MMS, RCS, WHATSAPP, VIBER, P2P. When omitted, defaults to all non-P2P types.
|
|
52
53
|
* @param {string|string[]} [params.channel] - Filter messages by channel. Accepts a single value or an array. Allowed values: tenDLC, virtualLongCode, tollFree, shortCode, p2p. Each message records its channel when it is saved, and this filters on that stored value; older messages from before this feature have no channel and count as tenDLC. Ignored when matchAny is true (matchAny takes precedence).
|
|
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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Accepted whether or not the environment serves hourly analytics.
|
|
54
55
|
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Accepted whether or not the environment serves hourly analytics.
|
|
55
56
|
* @param {boolean} [params.matchAny] - When true, the provided campaignId/brandId/phoneNumber filters are OR'd (a message matches ANY of them) instead of the default most-specific-single behavior. subgroupId stays an AND scope. Opt-in/additive.
|
|
56
57
|
* @param {string} [params.carrier] - Filter messages by the carrier used for sending
|
|
57
58
|
* @param {string|string[]} [params.sentimentLabel] - Filter messages by sentiment bucket. Accepts a single value or an array (e.g. ["positive", "negative"]). Allowed values: positive, neutral, negative. Applied as the sentimentScore range the ±25 label threshold produces, so unscored messages match no bucket and outbound messages (never scored) are excluded.
|
|
58
59
|
* @param {string|string[]} [params.errorCode] - Filter FAILED messages by Signal House error code (single value or array). "OUT" is the campaign opt-out, displayed as RECIPIENT_OPTED_OUT. Carrier codes are not filterable here; they live inside successOrFailureReason.
|
|
59
60
|
* @param {string|string[]} [params.phoneNumber] - Filter messages by a business number on either side of the message. Accepts a single value or an array; OR'd with campaignId/brandId when matchAny is true
|
|
60
|
-
* @param {string} [params.senderPhoneNumber] - Filter messages by the sender's 5-6 digit Short Code or 10+ digit phone number
|
|
61
|
-
* @param {string} [params.recipientPhoneNumber] - Filter messages by the recipient's phone number
|
|
61
|
+
* @param {string} [params.senderPhoneNumber] - Filter messages by the sender's 5-6 digit Short Code or 10+ digit phone number. Use % as a wildcard for a partial match (e.g. "%1234" matches numbers ending in 1234); a plain value is an exact match. 3-15 digits required alongside any %.
|
|
62
|
+
* @param {string} [params.recipientPhoneNumber] - Filter messages by the recipient's phone number. Use % as a wildcard for a partial match (e.g. "%1234" matches numbers ending in 1234); a plain value is an exact match. 3-15 digits required alongside any %.
|
|
62
63
|
* @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
|
|
63
64
|
* @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
|
|
64
65
|
* @param {string} [params.sortField] - The field to sort the messages by (createdAt, segmentCount, status, sentimentScore)
|
|
@@ -143,7 +144,7 @@ export class Messages {
|
|
|
143
144
|
* @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.
|
|
144
145
|
* @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.
|
|
145
146
|
* @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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
147
148
|
* @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.
|
|
148
149
|
* @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".
|
|
149
150
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
@@ -179,7 +180,7 @@ export class Messages {
|
|
|
179
180
|
* @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.
|
|
180
181
|
* @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.
|
|
181
182
|
* @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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
183
184
|
* @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.
|
|
184
185
|
* @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.
|
|
185
186
|
* @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.
|
|
@@ -234,7 +235,7 @@ export class Messages {
|
|
|
234
235
|
* @roles api, admin, developer, billing, user
|
|
235
236
|
* @param {Object} params - The parameters for getting analytics filter options
|
|
236
237
|
* @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.
|
|
238
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
238
239
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
239
240
|
* @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.
|
|
240
241
|
*/
|
|
@@ -265,7 +266,7 @@ export class Messages {
|
|
|
265
266
|
* @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).
|
|
266
267
|
* @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.
|
|
267
268
|
* @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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
269
270
|
* @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.
|
|
270
271
|
* @param {RequestOptions} [params.options]
|
|
271
272
|
* @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).
|
|
@@ -297,7 +298,7 @@ export class Messages {
|
|
|
297
298
|
* @param {number} [params.limit=50] - max 50 per page
|
|
298
299
|
* @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.
|
|
299
300
|
* @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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
301
302
|
* @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.
|
|
302
303
|
* @param {RequestOptions} [params.options]
|
|
303
304
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, totalErrors: { sms, mms, p2p, all }, page, limit }
|
|
@@ -324,7 +325,7 @@ export class Messages {
|
|
|
324
325
|
* @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
|
|
325
326
|
* @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.
|
|
326
327
|
* @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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
328
329
|
* @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.
|
|
329
330
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
330
331
|
* @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.
|
|
@@ -355,7 +356,7 @@ export class Messages {
|
|
|
355
356
|
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
356
357
|
* @param {string|string[]} [params.channel] - Filter by channel (tenDLC, virtualLongCode, tollFree, shortCode). Opt-outs are A2P-only, so p2p applies no filter. Filters on the stored channel column; a tenDLC selection also includes older opt-outs that have no channel.
|
|
357
358
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
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 {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
359
360
|
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
360
361
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
361
362
|
* @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).
|
|
@@ -381,7 +382,7 @@ export class Messages {
|
|
|
381
382
|
* @async
|
|
382
383
|
* @roles api, admin, developer, billing, user
|
|
383
384
|
* @param {Object} params - The parameters for sending an SMS message
|
|
384
|
-
* @param {string} params.senderPhoneNumber - The 5-6 digit Short Code or 10+ digit phone number to send the message from
|
|
385
|
+
* @param {string} params.senderPhoneNumber - The 5-6 digit Short Code or 10+ digit phone number to send the message from, or a READY alphanumeric sender ID (e.g. "ACME"; UK recipients and SMS only). Every message from an alphanumeric sender gets "\nOpt out: sihou.io/o/{code}" appended by the server, counted in segments.
|
|
385
386
|
* @param {string|string[]} params.recipientPhoneNumbers - The 10+ digit phone number(s) to send the message to. A Short Code sender permits exactly one recipient, and it must be a +1 (US/Canada) number; a bare 10-digit number is treated as +1. The API rejects Short Code sends with multiple recipients or a non-+1 recipient.
|
|
386
387
|
* @param {string} params.messageBody - The body of the SMS message
|
|
387
388
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
|
@@ -39,6 +39,40 @@ export class Onboarding {
|
|
|
39
39
|
const safeGroupId = encodeURIComponent(groupId);
|
|
40
40
|
return this.client(`/group/onboarding/${safeGroupId}`, { method: "GET", ...options });
|
|
41
41
|
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Add an internal comment/note to a group's admin Pricing editor. Staff-only.
|
|
45
|
+
* @async
|
|
46
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
47
|
+
* @param {Object} params
|
|
48
|
+
* @param {string} params.groupId - The group ID to comment on
|
|
49
|
+
* @param {string} params.comment - The comment/note text
|
|
50
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
51
|
+
* @throws {Error} Throws an error if the groupId or comment parameter is missing
|
|
52
|
+
* @returns {Promise<SdkResponse<any>>} - The updated onboarding record
|
|
53
|
+
*/
|
|
54
|
+
addPricingComment: async ({ groupId, comment, options = {} }) => {
|
|
55
|
+
this.client._require({ groupId, comment });
|
|
56
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
57
|
+
return this.client(`/group/onboarding/${safeGroupId}/pricing-comments`, { method: "POST", body: { comment }, ...options });
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Add an internal comment/note to a group's admin Credits page. Staff-only.
|
|
62
|
+
* @async
|
|
63
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
64
|
+
* @param {Object} params
|
|
65
|
+
* @param {string} params.groupId - The group ID to comment on
|
|
66
|
+
* @param {string} params.comment - The comment/note text
|
|
67
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
68
|
+
* @throws {Error} Throws an error if the groupId or comment parameter is missing
|
|
69
|
+
* @returns {Promise<SdkResponse<any>>} - The updated onboarding record
|
|
70
|
+
*/
|
|
71
|
+
addCreditComment: async ({ groupId, comment, options = {} }) => {
|
|
72
|
+
this.client._require({ groupId, comment });
|
|
73
|
+
const safeGroupId = encodeURIComponent(groupId);
|
|
74
|
+
return this.client(`/group/onboarding/${safeGroupId}/credit-comments`, { method: "POST", body: { comment }, ...options });
|
|
75
|
+
},
|
|
42
76
|
};
|
|
43
77
|
}
|
|
44
78
|
}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Sender registrations for every jurisdiction and type: the catalog of what a region offers, retail quotes,
|
|
9
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
|
|
10
|
+
* (for VIRTUAL_LONG_CODE: quantity, useCases and the optional voice dossier; for GB ALPHANUMERIC_SENDER_ID: requestedSenderId,
|
|
11
|
+
* trafficOrigin, trafficType and the company details).
|
|
11
12
|
*/
|
|
12
13
|
export class Registrations {
|
|
13
14
|
constructor(client, enableAdmin) {
|
|
@@ -126,7 +127,7 @@ export class Registrations {
|
|
|
126
127
|
* @async
|
|
127
128
|
* @roles api, admin, developer, billing, user
|
|
128
129
|
* @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 {string} params.region - ISO-2 jurisdiction (US, GB or CA; any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
130
131
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
131
132
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { region, jurisdiction, sendingRequiresRegistration, registeredThrough, provisioning, types }
|
|
132
133
|
*/
|
|
@@ -138,13 +139,14 @@ export class Registrations {
|
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
141
|
* 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
|
+
* and monthlyAmount, the totals for the quantity (integer microdollars) and etaDays. GB ALPHANUMERIC_SENDER_ID
|
|
143
|
+
* quotes one ["SMS"] bundle (6000000 setup and 6000000 monthly by default).
|
|
142
144
|
* Unavailable (400) while the type cannot be acquired in the region.
|
|
143
145
|
* @async
|
|
144
146
|
* @roles api, admin, developer, billing, user
|
|
145
147
|
* @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 {string} params.region - ISO-2 jurisdiction (any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
149
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE, or ALPHANUMERIC_SENDER_ID for GB)
|
|
148
150
|
* @param {number} [params.quantity=1] - Number of numbers to quote (1-100)
|
|
149
151
|
* @param {string} [params.groupId] - Group to price for; staff only
|
|
150
152
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
@@ -214,26 +216,30 @@ export class Registrations {
|
|
|
214
216
|
|
|
215
217
|
/**
|
|
216
218
|
* 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
|
-
*
|
|
219
|
+
* useCases (1-10 descriptions), voice? } where voice is required exactly when capabilities include VOICE. For GB
|
|
220
|
+
* ALPHANUMERIC_SENDER_ID (capabilities ["SMS"]) it is { requestedSenderId (3-11 letters/digits/space/dot/dash,
|
|
221
|
+
* at least one letter), trafficOrigin (LOCAL | INTERNATIONAL), trafficType (TRANSACTIONAL | PROMOTIONAL),
|
|
222
|
+
* companyName, companyCountry, companyWebsite, industry, messageExample, senderRelationship? } where
|
|
223
|
+
* senderRelationship is required when requestedSenderId differs from companyName; quantity is always 1 and
|
|
224
|
+
* data.phoneNumbers carries the granted sender (e.g. ["ACME"]) once APPROVED.
|
|
225
|
+
* Pass options.idempotencyKey to make a retry safe: an identical retry with the same key replays the first response.
|
|
219
226
|
* Unavailable (400) while the type cannot be acquired in the region.
|
|
220
227
|
* @async
|
|
221
228
|
* @roles api, admin, developer, billing, user
|
|
222
229
|
* @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)
|
|
230
|
+
* @param {string} params.region - ISO-2 jurisdiction (any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
231
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE, or ALPHANUMERIC_SENDER_ID for GB)
|
|
225
232
|
* @param {string} params.subgroupId - Subgroup that will own the registration and any allocated numbers
|
|
226
|
-
* @param {string} params.clientRequestId - Idempotency key (UUID)
|
|
227
233
|
* @param {string[]} params.capabilities - One of the type's bundles, e.g. ["SMS"] or ["SMS", "VOICE"]
|
|
228
234
|
* @param {Object} params.data - The type's submission fields
|
|
229
235
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
230
236
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the created registration
|
|
231
237
|
*/
|
|
232
|
-
async createRegistration({ region, type, subgroupId,
|
|
233
|
-
this.client._require({ region, type, subgroupId,
|
|
238
|
+
async createRegistration({ region, type, subgroupId, capabilities, data, options = {} }) {
|
|
239
|
+
this.client._require({ region, type, subgroupId, capabilities, data });
|
|
234
240
|
return this.client("/registration", {
|
|
235
241
|
method: "POST",
|
|
236
|
-
body: { region, type, subgroupId,
|
|
242
|
+
body: { region, type, subgroupId, capabilities, data },
|
|
237
243
|
...options,
|
|
238
244
|
});
|
|
239
245
|
}
|
|
@@ -25,6 +25,36 @@ export class Shortlinks {
|
|
|
25
25
|
return this.client(`/shortlink/redirect/${safeShortlinkId}`, { method: "GET", ...options });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Get the recipient opt-out details behind an alphanumeric-sender opt-out link (sihou.io/o/{code})
|
|
30
|
+
* @async
|
|
31
|
+
* @roles public
|
|
32
|
+
* @param {Object} params - The parameters for getting the opt-out details
|
|
33
|
+
* @param {string} params.code - The opt-out code from the link
|
|
34
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
35
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ code, senderName, maskedRecipient, optedOut }`
|
|
36
|
+
*/
|
|
37
|
+
async getOptOut({ code, options = {} }) {
|
|
38
|
+
this.client._require({ code });
|
|
39
|
+
const safeCode = encodeURIComponent(code);
|
|
40
|
+
return this.client(`/shortlink/optout/${safeCode}`, { method: "GET", ...options });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Confirm the recipient opt-out behind an alphanumeric-sender opt-out link; idempotent
|
|
45
|
+
* @async
|
|
46
|
+
* @roles public
|
|
47
|
+
* @param {Object} params - The parameters for confirming the opt-out
|
|
48
|
+
* @param {string} params.code - The opt-out code from the link
|
|
49
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
50
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ code, senderName, maskedRecipient, optedOut: true }`
|
|
51
|
+
*/
|
|
52
|
+
async confirmOptOut({ code, options = {} }) {
|
|
53
|
+
this.client._require({ code });
|
|
54
|
+
const safeCode = encodeURIComponent(code);
|
|
55
|
+
return this.client(`/shortlink/optout/${safeCode}`, { method: "POST", ...options });
|
|
56
|
+
}
|
|
57
|
+
|
|
28
58
|
/**
|
|
29
59
|
* Get details of a shortlink by its ID, with optional filters
|
|
30
60
|
* @async
|