@signalhousellc/sdk 1.2.0 → 1.3.1
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/scripts/install-skills.mjs +0 -0
- package/src/SignalHouseSDK.js +4 -1
- package/src/domains/Agents.js +231 -0
- package/src/domains/Auth.js +4 -1
- package/src/domains/Messages.js +3 -3
- package/src/domains/Numbers.js +3 -2
- package/src/domains/Onboarding.js +34 -0
- package/src/domains/Registrations.js +4 -5
package/package.json
CHANGED
|
File without changes
|
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
|
@@ -65,8 +65,11 @@ export class Auth {
|
|
|
65
65
|
* @param {string} [params.psPartnerKey] - PartnerStack partner key (ps_partner_key) captured from a referral link
|
|
66
66
|
* @param {Object} [params.attribution] - Marketing attribution captured at signup
|
|
67
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, fbclid, referrer, landingUrl
|
|
68
|
+
* @param {Object} [params.attribution.firstTouch] - First-ever visit: utmSource, utmMedium, utmCampaign, utmTerm, utmContent, gclid, gbraid, wbraid, fbclid, msclkid, referrer, landingUrl, timestamp
|
|
69
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)
|
|
70
73
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
71
74
|
* @returns {Promise<SdkResponse<any>>} The response from the server (contains the JWT token)
|
|
72
75
|
*/
|
package/src/domains/Messages.js
CHANGED
|
@@ -183,7 +183,7 @@ export class Messages {
|
|
|
183
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.
|
|
184
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.
|
|
185
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.
|
|
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,
|
|
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, excluding P2P) 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.
|
|
187
187
|
* @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".
|
|
188
188
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
189
189
|
* @returns {Promise<SdkResponse<Array>>} - A promise that resolves to an array of analytics snapshot records. cardTotals and
|
|
@@ -229,7 +229,7 @@ export class Messages {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
* Get filter dropdown options (subgroups, brands, campaigns, phone numbers) for the Analytics page,
|
|
232
|
+
* Get filter dropdown options (subgroups, brands, campaigns, phone numbers, carriers) for the Analytics page,
|
|
233
233
|
* scoped to a single group. Sourced from ClickHouse — only items with at least one message are returned.
|
|
234
234
|
* @async
|
|
235
235
|
* @roles api, admin, developer, billing, user
|
|
@@ -237,7 +237,7 @@ export class Messages {
|
|
|
237
237
|
* @param {string} params.groupId - The ID of the group whose filter options to load
|
|
238
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.
|
|
239
239
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
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
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers, carriers }. Each phone number carries type (TOLL_FREE, SHORT_CODE, ALPHANUMERIC, VIRTUAL_LONG_NUMBER, ...) and country (ISO-2), null when unknown: TOLL_FREE, SHORT_CODE and ALPHANUMERIC are channels by type; any other US number is 10DLC and a non-US one is a Virtual Long Code. `carriers` is a plain array of carrier name strings.
|
|
241
241
|
*/
|
|
242
242
|
async getAnalyticsFilterOptions({ groupId, region, options = {} }) {
|
|
243
243
|
const filters = { groupId, region };
|
package/src/domains/Numbers.js
CHANGED
|
@@ -323,11 +323,12 @@ export class Numbers {
|
|
|
323
323
|
* @param {string} [params.status] - Filter by status (PENDING, IN_PROGRESS, COMPLETED, REJECTED, CANCELLED)
|
|
324
324
|
* @param {number} [params.page] - The page number for pagination (default: 1)
|
|
325
325
|
* @param {number} [params.limit] - The number of items per page (default: 20)
|
|
326
|
+
* @param {boolean} [params.excludeDocuments] - When true, leave signatureUrl and billingUrl out of each request (the inline LOA signature and billing statement). Fetch one request with getPortRequestById to read them.
|
|
326
327
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
327
328
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the paginated list of port-in requests
|
|
328
329
|
*/
|
|
329
|
-
async getPortRequests({ groupId, phoneNumber, status, page, limit, options = {} } = {}) {
|
|
330
|
-
const filters = { groupId, phoneNumber, status, page, limit };
|
|
330
|
+
async getPortRequests({ groupId, phoneNumber, status, page, limit, excludeDocuments, options = {} } = {}) {
|
|
331
|
+
const filters = { groupId, phoneNumber, status, page, limit, excludeDocuments };
|
|
331
332
|
const queryString = this.client._getQueryString(filters);
|
|
332
333
|
return this.client(`/number/portin${queryString}`, { method: 'GET', ...options });
|
|
333
334
|
}
|
|
@@ -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
|
}
|
|
@@ -222,7 +222,7 @@ export class Registrations {
|
|
|
222
222
|
* companyName, companyCountry, companyWebsite, industry, messageExample, senderRelationship? } where
|
|
223
223
|
* senderRelationship is required when requestedSenderId differs from companyName; quantity is always 1 and
|
|
224
224
|
* data.phoneNumbers carries the granted sender (e.g. ["ACME"]) once APPROVED.
|
|
225
|
-
*
|
|
225
|
+
* Pass options.idempotencyKey to make a retry safe: an identical retry with the same key replays the first response.
|
|
226
226
|
* Unavailable (400) while the type cannot be acquired in the region.
|
|
227
227
|
* @async
|
|
228
228
|
* @roles api, admin, developer, billing, user
|
|
@@ -230,17 +230,16 @@ export class Registrations {
|
|
|
230
230
|
* @param {string} params.region - ISO-2 jurisdiction (any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
231
231
|
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE, or ALPHANUMERIC_SENDER_ID for GB)
|
|
232
232
|
* @param {string} params.subgroupId - Subgroup that will own the registration and any allocated numbers
|
|
233
|
-
* @param {string} params.clientRequestId - Idempotency key (UUID)
|
|
234
233
|
* @param {string[]} params.capabilities - One of the type's bundles, e.g. ["SMS"] or ["SMS", "VOICE"]
|
|
235
234
|
* @param {Object} params.data - The type's submission fields
|
|
236
235
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
237
236
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the created registration
|
|
238
237
|
*/
|
|
239
|
-
async createRegistration({ region, type, subgroupId,
|
|
240
|
-
this.client._require({ region, type, subgroupId,
|
|
238
|
+
async createRegistration({ region, type, subgroupId, capabilities, data, options = {} }) {
|
|
239
|
+
this.client._require({ region, type, subgroupId, capabilities, data });
|
|
241
240
|
return this.client("/registration", {
|
|
242
241
|
method: "POST",
|
|
243
|
-
body: { region, type, subgroupId,
|
|
242
|
+
body: { region, type, subgroupId, capabilities, data },
|
|
244
243
|
...options,
|
|
245
244
|
});
|
|
246
245
|
}
|