@signalhouse-sms/sdk 1.14.0 → 1.15.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 +3 -0
- package/src/domains/Brands.js +1 -1
- package/src/domains/Compliance.js +324 -0
- package/src/domains/Subgroups.js +51 -0
- package/src/domains/Voice.js +3 -0
- package/src/domains/voice/CallFlows.js +243 -0
- package/src/domains/voice/NumberRoutes.js +2 -1
- package/src/domains/voice/ProgrammableVoiceProfiles.js +4 -2
- package/types/SignalHouseSDK.d.ts +2 -0
- package/types/domains/Brands.d.ts +1 -1
- package/types/domains/Compliance.d.ts +325 -0
- package/types/domains/Subgroups.d.ts +51 -0
- package/types/domains/Voice.d.ts +3 -0
- package/types/domains/voice/CallFlows.d.ts +319 -0
- package/types/domains/voice/NumberRoutes.d.ts +8 -3
- package/types/domains/voice/ProgrammableVoiceProfiles.d.ts +16 -6
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -50,6 +50,7 @@ import { Agents } from "./domains/Agents.js";
|
|
|
50
50
|
import { Audit } from "./domains/Audit.js";
|
|
51
51
|
import { Contracts } from "./domains/Contracts.js";
|
|
52
52
|
import { Verify } from "./domains/Verify.js";
|
|
53
|
+
import { Compliance } from "./domains/Compliance.js";
|
|
53
54
|
|
|
54
55
|
export class SignalHouseSDK {
|
|
55
56
|
/**
|
|
@@ -105,6 +106,8 @@ export class SignalHouseSDK {
|
|
|
105
106
|
this.contracts = new Contracts(client, this.enableAdmin);
|
|
106
107
|
// Carrier phone-number checks (SIM Swap, Number Verify) under /verify.
|
|
107
108
|
this.verify = new Verify(client, this.enableAdmin);
|
|
109
|
+
// Compliance cases under /compliance; staff methods under compliance.admin.
|
|
110
|
+
this.compliance = new Compliance(client, multipartClient, this.enableAdmin);
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
/**
|
package/src/domains/Brands.js
CHANGED
|
@@ -546,7 +546,7 @@ export class Brands {
|
|
|
546
546
|
* @param {File|Blob} params.file - The supporting document file
|
|
547
547
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
548
548
|
* @throws {Error} Throws an error if required parameters are missing
|
|
549
|
-
* @returns {Promise<SdkResponse<any>>} The response from the server
|
|
549
|
+
* @returns {Promise<SdkResponse<any>>} The response from the server. When TCR refuses the appeal itself (a 4xx, e.g. code 592 for a brand older than 45 days), the error body is { error: "TCR refused the appeal: <reason>", details: { code, message } } with TCR's own code and message. Don't retry it unchanged; it will be refused again.
|
|
550
550
|
*/
|
|
551
551
|
async submitAppeal({ brandId, appealCategories, explanation, file, options = {} }) {
|
|
552
552
|
this.client._require({ brandId, appealCategories, explanation, file });
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compliance cases under /compliance. Signal House opens a case when a carrier suspends one of your objects, a carrier
|
|
9
|
+
* escalates a message, or Signal House needs something from you. You read your cases, answer their requirements and
|
|
10
|
+
* upload files; only Signal House opens, works and closes them. Staff methods are under `admin` (enableAdmin).
|
|
11
|
+
*/
|
|
12
|
+
export class Compliance {
|
|
13
|
+
/**
|
|
14
|
+
* Keep the JSON and multipart clients every compliance request goes through.
|
|
15
|
+
* @param {any} client - The JSON request client
|
|
16
|
+
* @param {any} multipartClient - The multipart request client, for file uploads
|
|
17
|
+
* @param {boolean} [enableAdmin] - Whether the staff methods under `admin` are available
|
|
18
|
+
*/
|
|
19
|
+
constructor(client, multipartClient, enableAdmin) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
this.multipartClient = multipartClient;
|
|
22
|
+
this.enableAdmin = enableAdmin;
|
|
23
|
+
|
|
24
|
+
if (enableAdmin) {
|
|
25
|
+
this.admin = {
|
|
26
|
+
/**
|
|
27
|
+
* Log an alert by hand: a reading, a notice or a block. Blocks (and a Sev-0 carrier ticket) need signalhouse_admin.
|
|
28
|
+
* @async
|
|
29
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
30
|
+
* @param {Object} params - The alert
|
|
31
|
+
* @param {Object} params.data - `{ form, type, subject: { kind, id }, ... }`: the intake input without a raw payload
|
|
32
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
33
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ logged, recovered, updated, unmatched, duplicate }`
|
|
34
|
+
*/
|
|
35
|
+
logAlert: async ({ data, options = {} }) => {
|
|
36
|
+
this.client._require({ data });
|
|
37
|
+
return this.client(`/compliance/alerts`, { method: "POST", body: data, ...options });
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Lift a block by hand. signalhouse_admin only.
|
|
42
|
+
* @async
|
|
43
|
+
* @roles signalhouse_admin
|
|
44
|
+
* @param {Object} params - The lift
|
|
45
|
+
* @param {string} params.alertId - The block alert (ALR-…)
|
|
46
|
+
* @param {string} [params.note] - Why it lifted
|
|
47
|
+
* @param {string} [params.occurredAt] - When the source says it lifted (ISO 8601)
|
|
48
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
49
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ alertId, recoveredAt, caseId, caseClosed, closeReason }`
|
|
50
|
+
*/
|
|
51
|
+
liftBlock: async ({ alertId, note, occurredAt, options = {} }) => {
|
|
52
|
+
this.client._require({ alertId });
|
|
53
|
+
const body = { ...(note !== undefined && { note }), ...(occurredAt !== undefined && { occurredAt }) };
|
|
54
|
+
return this.client(`/compliance/alerts/${encodeURIComponent(alertId)}/lift`, { method: "POST", body, ...options });
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List alerts, with the inbox counts.
|
|
59
|
+
* @async
|
|
60
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
61
|
+
* @param {Object} [params] - Filters: type, form, severity, channel, source, subjectKind, subjectId, number, groupId, subgroupId, campaignId, caseId, inbox, open, blocks, slackPending, from, to, page, limit
|
|
62
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
63
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ data, total, page, limit, totalPages, counts: { inCase, inbox, noted } }`
|
|
64
|
+
*/
|
|
65
|
+
getAlerts: async ({ options = {}, ...filters } = {}) => {
|
|
66
|
+
return this.client(`/compliance/alerts${this.client._getQueryString(filters)}`, { method: "GET", ...options });
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get one alert with its raw payload, escalation chain, case summary and timeline.
|
|
71
|
+
* @async
|
|
72
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
73
|
+
* @param {Object} params - The lookup
|
|
74
|
+
* @param {string} params.alertId - The alert (ALR-…)
|
|
75
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
76
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the alert with `chain`, `case` and `timeline`
|
|
77
|
+
*/
|
|
78
|
+
getAlert: async ({ alertId, options = {} }) => {
|
|
79
|
+
this.client._require({ alertId });
|
|
80
|
+
return this.client(`/compliance/alerts/${encodeURIComponent(alertId)}`, { method: "GET", ...options });
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Work an inbox alert: `{ action: "assign", caseId }`, `{ action: "assign", object: { objectType, objectId } }` or `{ action: "note", note }`.
|
|
85
|
+
* @async
|
|
86
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
87
|
+
* @param {Object} params - The action
|
|
88
|
+
* @param {string} params.alertId - The inbox alert (ALR-…)
|
|
89
|
+
* @param {Object} params.data - The action body
|
|
90
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
91
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the alert after the action
|
|
92
|
+
*/
|
|
93
|
+
triageAlert: async ({ alertId, data, options = {} }) => {
|
|
94
|
+
this.client._require({ alertId, data });
|
|
95
|
+
return this.client(`/compliance/alerts/${encodeURIComponent(alertId)}`, { method: "PUT", body: data, ...options });
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Open a case by hand to send the customer a notice; its requirements go out at once. 409 when the object already has an open case.
|
|
100
|
+
* @async
|
|
101
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
102
|
+
* @param {Object} params - The case
|
|
103
|
+
* @param {Object} params.data - `{ objectType, objectId, reasonTemplate, reason?, customerNote?, requirements: [{ kind, text }], fixByDays? }`
|
|
104
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
105
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
106
|
+
*/
|
|
107
|
+
openCase: async ({ data, options = {} }) => {
|
|
108
|
+
this.client._require({ data });
|
|
109
|
+
return this.client(`/compliance/cases`, { method: "POST", body: data, ...options });
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Take, give or release ownership (assigneeUserId, null to release), and edit reasonTemplate, reason and customerNote.
|
|
114
|
+
* @async
|
|
115
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
116
|
+
* @param {Object} params - The change
|
|
117
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
118
|
+
* @param {Object} params.data - `{ assigneeUserId?, reasonTemplate?, reason?, customerNote? }`
|
|
119
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
120
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
121
|
+
*/
|
|
122
|
+
updateCase: async ({ caseId, data, options = {} }) => {
|
|
123
|
+
this.client._require({ caseId, data });
|
|
124
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}`, { method: "PUT", body: data, ...options });
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Send requirements the first time, or add more; either hands the case to the customer.
|
|
129
|
+
* @async
|
|
130
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
131
|
+
* @param {Object} params - The requirements
|
|
132
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
133
|
+
* @param {Array<{kind: string, text: string}>} params.requirements - RECORDS, CAMPAIGN_EDIT, NUMBER_ACTION or CONFIRM, with the text
|
|
134
|
+
* @param {number} [params.fixByDays] - Days until they are due, 1-14 (default 5)
|
|
135
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
136
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
137
|
+
*/
|
|
138
|
+
sendRequirements: async ({ caseId, requirements, fixByDays, options = {} }) => {
|
|
139
|
+
this.client._require({ caseId, requirements });
|
|
140
|
+
const body = { requirements, ...(fixByDays !== undefined && { fixByDays }) };
|
|
141
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/requirements`, { method: "PUT", body, ...options });
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Record that the lift request went upstream. The case must hold an open carrier suspension or provider pause.
|
|
146
|
+
* @async
|
|
147
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
148
|
+
* @param {Object} params - The request
|
|
149
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
150
|
+
* @param {string} [params.note] - What was sent
|
|
151
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
152
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
153
|
+
*/
|
|
154
|
+
requestLift: async ({ caseId, note, options = {} }) => {
|
|
155
|
+
this.client._require({ caseId });
|
|
156
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/lift-request`, { method: "POST", body: { ...(note !== undefined && { note }) }, ...options });
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Close a case. Lift its open blocks first.
|
|
161
|
+
* @async
|
|
162
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
163
|
+
* @param {Object} params - The close
|
|
164
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
165
|
+
* @param {string} params.closeReason - CUSTOMER_REMEDIATED, SUSPENDED_BY_CARRIER, LIFTED, LABEL_REMOVED, TRACEBACK_ANSWERED, FALSE_POSITIVE or CLEARED
|
|
166
|
+
* @param {string} [params.closeNote] - Why
|
|
167
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
168
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the closed case
|
|
169
|
+
*/
|
|
170
|
+
closeCase: async ({ caseId, closeReason, closeNote, options = {} }) => {
|
|
171
|
+
this.client._require({ caseId, closeReason });
|
|
172
|
+
const body = { closeReason, ...(closeNote !== undefined && { closeNote }) };
|
|
173
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/close`, { method: "POST", body, ...options });
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Email the customer a reminder of the requirements still open.
|
|
178
|
+
* @async
|
|
179
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
180
|
+
* @param {Object} params - The reminder
|
|
181
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
182
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
183
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
184
|
+
*/
|
|
185
|
+
remindCase: async ({ caseId, options = {} }) => {
|
|
186
|
+
this.client._require({ caseId });
|
|
187
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/reminder`, { method: "POST", body: {}, ...options });
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Add a staff note, or an email to or from the upstream, to a case's history.
|
|
192
|
+
* @async
|
|
193
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
194
|
+
* @param {Object} params - The note
|
|
195
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
196
|
+
* @param {string} params.kind - STAFF, EMAIL_IN or EMAIL_OUT
|
|
197
|
+
* @param {string} params.text - The note
|
|
198
|
+
* @param {{from?: string, to?: string, subject?: string, body?: string}} [params.email] - The email, on EMAIL_IN and EMAIL_OUT
|
|
199
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
200
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the staff view of the case
|
|
201
|
+
*/
|
|
202
|
+
addCaseNote: async ({ caseId, kind, text, email, options = {} }) => {
|
|
203
|
+
this.client._require({ caseId, kind, text });
|
|
204
|
+
const body = { kind, text, ...(email !== undefined && { email }) };
|
|
205
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/note`, { method: "POST", body, ...options });
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get a group's strikes in the last 90 days, the block periods behind them, and whether an open case carries the review flag.
|
|
210
|
+
* @async
|
|
211
|
+
* @roles signalhouse_admin, signalhouse_user
|
|
212
|
+
* @param {Object} params - The lookup
|
|
213
|
+
* @param {string} params.groupId - The group
|
|
214
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
215
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ groupId, windowDays, strikes, reviewDue, periods }`
|
|
216
|
+
*/
|
|
217
|
+
getStrikes: async ({ groupId, options = {} }) => {
|
|
218
|
+
this.client._require({ groupId });
|
|
219
|
+
return this.client(`/compliance/strikes/${encodeURIComponent(groupId)}`, { method: "GET", ...options });
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* List the compliance cases you can see, newest first. `counts.waitingOnYou` is the open cases with requirements still to answer
|
|
227
|
+
* @async
|
|
228
|
+
* @roles api, admin, developer, billing, user
|
|
229
|
+
* @param {Object} [params] - Filters
|
|
230
|
+
* @param {string} [params.groupId] - A group you can view; defaults to your active group
|
|
231
|
+
* @param {string} [params.status] - OPEN, LIFT_REQUESTED or CLOSED
|
|
232
|
+
* @param {string} [params.stage] - new, customer, ready, lift_requested or closed
|
|
233
|
+
* @param {string} [params.objectType] - CAMPAIGN, BRAND, NUMBER, RCS_AGENT or SUBGROUP
|
|
234
|
+
* @param {string} [params.objectId] - The object's id
|
|
235
|
+
* @param {string} [params.subgroupId] - Only cases in this subgroup
|
|
236
|
+
* @param {boolean} [params.suspended] - true for cases with an open suspension or hold, false for the rest
|
|
237
|
+
* @param {string} [params.from] - Opened on or after this ISO 8601 time
|
|
238
|
+
* @param {string} [params.to] - Opened on or before this ISO 8601 time
|
|
239
|
+
* @param {string} [params.sort] - createdAt (default), fixBy or severity
|
|
240
|
+
* @param {number} [params.page] - Page number, from 1
|
|
241
|
+
* @param {number} [params.limit] - Cases per page, 1-200
|
|
242
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
243
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ data, total, page, limit, totalPages, counts: { open, waitingOnYou } }`
|
|
244
|
+
*/
|
|
245
|
+
async getCases({ groupId, status, stage, objectType, objectId, subgroupId, suspended, from, to, sort, page, limit, options = {} } = {}) {
|
|
246
|
+
const query = this.client._getQueryString({ groupId, status, stage, objectType, objectId, subgroupId, suspended, from, to, sort, page, limit });
|
|
247
|
+
return this.client(`/compliance/cases${query}`, { method: "GET", ...options });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Get one compliance case: its stage, suspensions, tickets and requirements
|
|
252
|
+
* @async
|
|
253
|
+
* @roles api, admin, developer, billing, user
|
|
254
|
+
* @param {Object} params - The lookup
|
|
255
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
256
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
257
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the case
|
|
258
|
+
*/
|
|
259
|
+
async getCase({ caseId, options = {} }) {
|
|
260
|
+
this.client._require({ caseId });
|
|
261
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}`, { method: "GET", ...options });
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Answer one requirement with a note, files, or both. A RECORDS requirement needs a file or a note
|
|
266
|
+
* @async
|
|
267
|
+
* @roles api, admin, developer, user
|
|
268
|
+
* @param {Object} params - The answer
|
|
269
|
+
* @param {string} params.caseId - The case (CASE-…)
|
|
270
|
+
* @param {string} params.requirementId - The requirement (CASE-…-n)
|
|
271
|
+
* @param {string} [params.answer] - What you did, up to 2,000 characters
|
|
272
|
+
* @param {string[]} [params.fileIds] - Up to 10 fileIds from uploadFile, on this case
|
|
273
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
274
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the case
|
|
275
|
+
*/
|
|
276
|
+
async answerRequirement({ caseId, requirementId, answer, fileIds, options = {} }) {
|
|
277
|
+
this.client._require({ caseId, requirementId });
|
|
278
|
+
const body = { ...(answer !== undefined && { answer }), ...(fileIds !== undefined && { fileIds }) };
|
|
279
|
+
return this.client(`/compliance/cases/${encodeURIComponent(caseId)}/requirements/${encodeURIComponent(requirementId)}`, { method: "PUT", body, ...options });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Upload a file to a compliance case (CSV, XLSX, PDF, PNG, JPG or TXT, up to 10 MB). Pass the returned fileId in
|
|
284
|
+
* fileIds when you answer the requirement
|
|
285
|
+
* @async
|
|
286
|
+
* @roles api, admin, developer, user
|
|
287
|
+
* @param {Object} params - The upload
|
|
288
|
+
* @param {string} params.caseId - The case the file answers
|
|
289
|
+
* @param {string} [params.requirementId] - The requirement the file answers
|
|
290
|
+
* @param {Blob|File} params.file - The file, as a Blob/File
|
|
291
|
+
* @param {string} [params.fileName] - Multipart filename; required for a CSV/TXT Blob without a name
|
|
292
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
293
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ fileId, fileName, mimeType, size }`
|
|
294
|
+
*/
|
|
295
|
+
async uploadFile({ caseId, requirementId, file, fileName, options = {} }) {
|
|
296
|
+
this.client._require({ caseId, file });
|
|
297
|
+
const name = fileName ?? ("name" in file && typeof file.name === "string" ? file.name : undefined);
|
|
298
|
+
if (!name && ["text/csv", "text/plain"].includes(file.type.split(";")[0])) {
|
|
299
|
+
const error = new Error("CSV/TXT Blob uploads require fileName (for example records.csv), or a named File.");
|
|
300
|
+
error.name = "SignalHouseValidationError";
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
const formData = new FormData();
|
|
304
|
+
formData.append("caseId", caseId);
|
|
305
|
+
if (requirementId) formData.append("requirementId", requirementId);
|
|
306
|
+
if (name !== undefined) formData.append("file", file, name);
|
|
307
|
+
else formData.append("file", file);
|
|
308
|
+
return this.multipartClient(`/compliance/files`, { method: "POST", body: formData, ...options });
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Download a compliance file
|
|
313
|
+
* @async
|
|
314
|
+
* @roles api, admin, developer, billing, user
|
|
315
|
+
* @param {Object} params - The lookup
|
|
316
|
+
* @param {string} params.fileId - The fileId uploadFile returned
|
|
317
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
318
|
+
* @returns {Promise<SdkResponse<ArrayBuffer>>} A promise that resolves to the file bytes as an ArrayBuffer
|
|
319
|
+
*/
|
|
320
|
+
async getFile({ fileId, options = {} }) {
|
|
321
|
+
this.client._require({ fileId });
|
|
322
|
+
return this.client(`/compliance/files/${encodeURIComponent(fileId)}`, { method: "GET", responseType: "arraybuffer", ...options });
|
|
323
|
+
}
|
|
324
|
+
}
|
package/src/domains/Subgroups.js
CHANGED
|
@@ -48,6 +48,37 @@ export class Subgroups {
|
|
|
48
48
|
constructor(client, enableAdmin) {
|
|
49
49
|
this.client = client;
|
|
50
50
|
this.enableAdmin = enableAdmin;
|
|
51
|
+
|
|
52
|
+
// Hidden Admin namespace INSIDE the domain
|
|
53
|
+
if (enableAdmin) {
|
|
54
|
+
this.admin = {
|
|
55
|
+
/**
|
|
56
|
+
* Link (or, with ghlLocationId: null, unlink) a GoHighLevel location to a subgroup. At most
|
|
57
|
+
* one subgroup may hold a given ghlLocationId; linking it here steals it from any other
|
|
58
|
+
* subgroup that currently holds it. Intended for ghl-app/backend's write-through right after
|
|
59
|
+
* it locally claims a location -> subgroup link.
|
|
60
|
+
* @async
|
|
61
|
+
* @roles signalhouse_api, signalhouse_admin
|
|
62
|
+
* @param {Object} params - The parameters for linking a GHL location
|
|
63
|
+
* @param {string} params.subgroupId - The subgroup to link
|
|
64
|
+
* @param {string|null} params.ghlLocationId - The GHL location ID to link, or null to unlink
|
|
65
|
+
* @param {string|null} [params.ghlLocationName] - Display name of the GHL location. Omit to leave the
|
|
66
|
+
* subgroup's currently stored name untouched (only when ghlLocationId is unchanged - otherwise
|
|
67
|
+
* cleared to null); always cleared to null when unlinking
|
|
68
|
+
* @param {Date|string} [params.claimedAt] - When this link was locally claimed by the caller.
|
|
69
|
+
* Required when linking (ghlLocationId is non-null) - used to detect and reject a delayed/
|
|
70
|
+
* out-of-order push whose claim has since been superseded by a newer one recorded elsewhere.
|
|
71
|
+
* Ignored when unlinking.
|
|
72
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
73
|
+
* @throws {Error} Throws an error if the subgroupId parameter is missing
|
|
74
|
+
* @returns {Promise<SdkResponse<any>>} - The updated subgroup object returned from the server
|
|
75
|
+
*/
|
|
76
|
+
linkGhlLocation: async ({ subgroupId, ghlLocationId, ghlLocationName, claimedAt, options = {} }) => {
|
|
77
|
+
this.client._require({ subgroupId });
|
|
78
|
+
return this.client(`/subgroup/ghl-location-link`, { method: "PUT", body: { subgroupId, ghlLocationId, ghlLocationName, claimedAt }, ...options });
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
51
82
|
}
|
|
52
83
|
|
|
53
84
|
/**
|
|
@@ -118,6 +149,26 @@ export class Subgroups {
|
|
|
118
149
|
return this.client(`/subgroup/${safeId}`, { method: "PUT", body: updateData, ...options });
|
|
119
150
|
}
|
|
120
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Resolve the mapping between a GoHighLevel location and a Signal House subgroup, in either
|
|
154
|
+
* direction. Provide exactly one of ghlLocationId or subgroupId. groupId is optional - customer
|
|
155
|
+
* roles default to their own accessible group(s) and are rejected if they name a group they don't
|
|
156
|
+
* belong to; a subgroupId/ghlLocationId that belongs to a different group than the caller's returns
|
|
157
|
+
* a 404, identical to a nonexistent one.
|
|
158
|
+
* @async
|
|
159
|
+
* @roles api, admin, developer, billing, user
|
|
160
|
+
* @param {Object} params - The parameters for the lookup
|
|
161
|
+
* @param {string} [params.groupId] - Restrict the lookup to an accessible group ID
|
|
162
|
+
* @param {string} [params.ghlLocationId] - GHL location ID to resolve to its subgroup (mutually exclusive with subgroupId)
|
|
163
|
+
* @param {string} [params.subgroupId] - Subgroup ID to resolve to its GHL location (mutually exclusive with ghlLocationId)
|
|
164
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
165
|
+
* @returns {Promise<SdkResponse<any>>} - `{ groupId, subgroupId, subgroupName, ghlLocationId, ghlLocationName }`
|
|
166
|
+
*/
|
|
167
|
+
async lookupGhlLocation({ groupId, ghlLocationId, subgroupId, options = {} } = {}) {
|
|
168
|
+
const queryString = this.client._getQueryString({ groupId, ghlLocationId, subgroupId });
|
|
169
|
+
return this.client(`/subgroup/ghl-location-lookup${queryString}`, { method: "GET", ...options });
|
|
170
|
+
}
|
|
171
|
+
|
|
121
172
|
/**
|
|
122
173
|
* Delete a subgroup by its ID (mark as inactive)
|
|
123
174
|
* @async
|
package/src/domains/Voice.js
CHANGED
|
@@ -8,6 +8,7 @@ import { GlobalVoiceSettings } from "./voice/GlobalVoiceSettings.js";
|
|
|
8
8
|
import { Tokens } from "./voice/Tokens.js";
|
|
9
9
|
import { Analytics } from "./voice/Analytics.js";
|
|
10
10
|
import { OutboundVoice } from "./voice/OutboundVoice.js";
|
|
11
|
+
import { CallFlows } from "./voice/CallFlows.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Voice domain — wraps the Voice service (mounted under /voice on the
|
|
@@ -19,6 +20,7 @@ import { OutboundVoice } from "./voice/OutboundVoice.js";
|
|
|
19
20
|
* - `sdk.voice.sipProfiles` — SIP profile / endpoint (single registerable UA).
|
|
20
21
|
* - `sdk.voice.programmableVoiceProfiles` — Programmable Voice Profile (route a set of numbers through Signal House).
|
|
21
22
|
* - `sdk.voice.numberRoutes` — Per-number inbound route (overrides the profile and subgroup settings).
|
|
23
|
+
* - `sdk.voice.callFlows` — Call flows: customer-built call trees a number or profile can run.
|
|
22
24
|
* - `sdk.voice.calls` — Twilio-compat programmatic call control (create/hangup/etc.).
|
|
23
25
|
* - `sdk.voice.callLogs` — Account-scoped call history: list/get + presigned recording.
|
|
24
26
|
* - `sdk.voice.globalVoiceSettings` — Account-wide voice defaults (accepted regions, max spend, E911).
|
|
@@ -39,5 +41,6 @@ export class Voice {
|
|
|
39
41
|
this.tokens = new Tokens(client, enableAdmin);
|
|
40
42
|
this.analytics = new Analytics(client, enableAdmin);
|
|
41
43
|
this.outboundVoice = new OutboundVoice(client, enableAdmin);
|
|
44
|
+
this.callFlows = new CallFlows(client, enableAdmin);
|
|
42
45
|
}
|
|
43
46
|
}
|