@unboundcx/sdk 4.13.137 → 4.13.139
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/services/phoneNumbers/carrier.js +60 -0
- package/services/phoneNumbers/cnam.js +42 -0
- package/services/phoneNumbers/index.js +27 -0
- package/services/phoneNumbers/order.js +88 -0
- package/services/phoneNumbers/porting-activity.js +289 -0
- package/services/phoneNumbers/porting-orders.js +318 -0
- package/services/phoneNumbers/search.js +181 -0
- package/services/phoneNumbers/update.js +94 -0
- package/services/phoneNumbers.js +2 -1037
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.139",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
// phoneNumbers/carrier.js :: PhoneNumberCarrierService :: carrier sync/lookup/delete for owned numbers
|
|
4
|
+
export class PhoneNumberCarrierService {
|
|
5
|
+
constructor(sdk) {
|
|
6
|
+
this.sdk = sdk;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async sync(carrier, { updateVoiceConnection, updateMessagingConnection }) {
|
|
10
|
+
this.sdk.validateParams(
|
|
11
|
+
{ carrier },
|
|
12
|
+
{
|
|
13
|
+
carrier: { type: 'string', required: true },
|
|
14
|
+
updateVoiceConnection: { type: 'boolean', required: false },
|
|
15
|
+
updateMessagingConnection: { type: 'boolean', required: false },
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const params = {
|
|
20
|
+
query: { updateVoiceConnection, updateMessagingConnection },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const result = await internalRequest(this.sdk,
|
|
24
|
+
`/phoneNumbers/carrier/syncPhoneNumbers/${carrier}`,
|
|
25
|
+
'POST',
|
|
26
|
+
params,
|
|
27
|
+
);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getDetails(phoneNumber) {
|
|
32
|
+
this.sdk.validateParams(
|
|
33
|
+
{ phoneNumber },
|
|
34
|
+
{
|
|
35
|
+
phoneNumber: { type: 'string', required: true },
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const result = await internalRequest(this.sdk,
|
|
40
|
+
`/phoneNumbers/carrier/${phoneNumber}`,
|
|
41
|
+
'GET',
|
|
42
|
+
);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async delete(phoneNumber) {
|
|
47
|
+
this.sdk.validateParams(
|
|
48
|
+
{ phoneNumber },
|
|
49
|
+
{
|
|
50
|
+
phoneNumber: { type: 'string', required: true },
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const result = await internalRequest(this.sdk,
|
|
55
|
+
`/phoneNumbers/carrier/${phoneNumber}`,
|
|
56
|
+
'DELETE',
|
|
57
|
+
);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
// phoneNumbers/cnam.js :: CNAM methods :: caller-id name enable/update + carrier check
|
|
4
|
+
export const cnamMethods = {
|
|
5
|
+
async updateCnam(id, { enabled, name }) {
|
|
6
|
+
this.sdk.validateParams(
|
|
7
|
+
{ id, enabled, name },
|
|
8
|
+
{
|
|
9
|
+
id: { type: 'string', required: true },
|
|
10
|
+
enabled: { type: 'boolean', required: true },
|
|
11
|
+
name: { type: 'string', required: false },
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const params = {
|
|
16
|
+
body: { enabled, ...(name !== undefined ? { name } : {}) },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const result = await internalRequest(this.sdk,
|
|
20
|
+
`/phoneNumbers/${id}/cnam`,
|
|
21
|
+
'PUT',
|
|
22
|
+
params,
|
|
23
|
+
);
|
|
24
|
+
return result;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
async checkCnam(id) {
|
|
28
|
+
this.sdk.validateParams(
|
|
29
|
+
{ id },
|
|
30
|
+
{
|
|
31
|
+
id: { type: 'string', required: true },
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const result = await internalRequest(this.sdk,
|
|
36
|
+
`/phoneNumbers/${id}/cnam/check`,
|
|
37
|
+
'POST',
|
|
38
|
+
{},
|
|
39
|
+
);
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { searchMethods } from './search.js';
|
|
2
|
+
import { orderMethods } from './order.js';
|
|
3
|
+
import { updateMethods } from './update.js';
|
|
4
|
+
import { cnamMethods } from './cnam.js';
|
|
5
|
+
import { portingOrderMethods } from './porting-orders.js';
|
|
6
|
+
import { portingActivityMethods } from './porting-activity.js';
|
|
7
|
+
import { PhoneNumberCarrierService } from './carrier.js';
|
|
8
|
+
|
|
9
|
+
// phoneNumbers/index.js :: PhoneNumbersService :: composes the split method modules back into one class
|
|
10
|
+
export class PhoneNumbersService {
|
|
11
|
+
constructor(sdk) {
|
|
12
|
+
this.sdk = sdk;
|
|
13
|
+
this.carrier = new PhoneNumberCarrierService(sdk);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Object.assign(
|
|
18
|
+
PhoneNumbersService.prototype,
|
|
19
|
+
searchMethods,
|
|
20
|
+
orderMethods,
|
|
21
|
+
updateMethods,
|
|
22
|
+
cnamMethods,
|
|
23
|
+
portingOrderMethods,
|
|
24
|
+
portingActivityMethods,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export { PhoneNumberCarrierService };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
// phoneNumbers/order.js :: order/remove methods :: buying + releasing numbers, bulk carrier auto-create
|
|
4
|
+
export const orderMethods = {
|
|
5
|
+
async order({ phoneNumbers, name }) {
|
|
6
|
+
this.sdk.validateParams(
|
|
7
|
+
{ phoneNumbers },
|
|
8
|
+
{
|
|
9
|
+
phoneNumbers: { type: 'array', required: true },
|
|
10
|
+
name: { type: 'string', required: false },
|
|
11
|
+
},
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const orderData = { phoneNumbers };
|
|
15
|
+
if (name) orderData.name = name;
|
|
16
|
+
|
|
17
|
+
const params = {
|
|
18
|
+
body: orderData,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const result = await internalRequest(this.sdk, '/phoneNumbers/order', 'POST', params);
|
|
22
|
+
return result;
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async remove(phoneNumber) {
|
|
26
|
+
this.sdk.validateParams(
|
|
27
|
+
{ phoneNumber },
|
|
28
|
+
{
|
|
29
|
+
phoneNumber: { type: 'string', required: true },
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const result = await internalRequest(this.sdk,
|
|
34
|
+
`/phoneNumbers/${phoneNumber}`,
|
|
35
|
+
'DELETE',
|
|
36
|
+
);
|
|
37
|
+
return result;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Auto-create porting orders by grouping phone numbers by carrier
|
|
42
|
+
*
|
|
43
|
+
* Analyzes phone numbers using internal LRN lookup, groups them by carrier,
|
|
44
|
+
* and either previews the groupings (dry run) or creates separate porting
|
|
45
|
+
* orders for each carrier group.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} params
|
|
48
|
+
* @param {string[]} params.phoneNumbers - Array of +E.164 formatted phone numbers (max 100)
|
|
49
|
+
* @param {string} params.name - Base name for orders (will be appended with carrier names)
|
|
50
|
+
* @param {boolean} [params.dryRun=false] - If true, returns preview without creating orders
|
|
51
|
+
* @returns {Promise<Object>} Carrier groups and creation results
|
|
52
|
+
* @example
|
|
53
|
+
* // Preview carrier groupings
|
|
54
|
+
* const preview = await sdk.phoneNumbers.autoCreateOrders({
|
|
55
|
+
* phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
|
|
56
|
+
* name: 'Q1 2025 Port',
|
|
57
|
+
* dryRun: true
|
|
58
|
+
* });
|
|
59
|
+
* // Returns carrier groups with proposed order names
|
|
60
|
+
*
|
|
61
|
+
* // Create orders for each carrier
|
|
62
|
+
* const result = await sdk.phoneNumbers.autoCreateOrders({
|
|
63
|
+
* phoneNumbers: ['+15551234567', '+15551234568', '+15551234569'],
|
|
64
|
+
* name: 'Q1 2025 Port',
|
|
65
|
+
* dryRun: false
|
|
66
|
+
* });
|
|
67
|
+
* // Returns created orders and any errors
|
|
68
|
+
*/
|
|
69
|
+
async autoCreateOrders({ phoneNumbers, name, dryRun = false }) {
|
|
70
|
+
this.sdk.validateParams(
|
|
71
|
+
{ phoneNumbers, name },
|
|
72
|
+
{
|
|
73
|
+
phoneNumbers: { type: 'array', required: true },
|
|
74
|
+
name: { type: 'string', required: true },
|
|
75
|
+
dryRun: { type: 'boolean', required: false },
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const result = await internalRequest(this.sdk,
|
|
80
|
+
'/phoneNumbers/porting/auto-create-orders',
|
|
81
|
+
'POST',
|
|
82
|
+
{
|
|
83
|
+
body: { phoneNumbers, name, dryRun },
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
return result;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { internalRequest } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
// phoneNumbers/porting-activity.js :: porting documents, LOA e-sign, events, sync, exceptions, comments
|
|
4
|
+
export const portingActivityMethods = {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Attach or update a document for a porting order
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} params
|
|
10
|
+
* @param {string} params.portingOrderId - Porting order ID
|
|
11
|
+
* @param {string} [params.storageId] - Storage ID of uploaded file (null to clear)
|
|
12
|
+
* @param {string} [params.documentType='loa'] - Document type (loa, bill, csr, etc.)
|
|
13
|
+
* @param {boolean} [params.isRequired=false] - Whether document is required
|
|
14
|
+
* @param {string} [params.documentId] - Optional: Update existing document by ID
|
|
15
|
+
* @returns {Promise<Object>} Document attachment result with action (created/updated)
|
|
16
|
+
*/
|
|
17
|
+
async attachPortingDocument({
|
|
18
|
+
portingOrderId,
|
|
19
|
+
storageId = null,
|
|
20
|
+
documentType = 'loa',
|
|
21
|
+
isRequired = false,
|
|
22
|
+
documentId = null,
|
|
23
|
+
}) {
|
|
24
|
+
this.sdk.validateParams(
|
|
25
|
+
{ portingOrderId, documentType },
|
|
26
|
+
{
|
|
27
|
+
portingOrderId: { type: 'string', required: true },
|
|
28
|
+
documentType: { type: 'string', required: true },
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const body = {
|
|
33
|
+
portingOrderId,
|
|
34
|
+
storageId,
|
|
35
|
+
documentType,
|
|
36
|
+
isRequired,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (documentId) body.documentId = documentId;
|
|
40
|
+
|
|
41
|
+
const result = await internalRequest(this.sdk,
|
|
42
|
+
'/phoneNumbers/porting/documents',
|
|
43
|
+
'POST',
|
|
44
|
+
{
|
|
45
|
+
body: body,
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
return result;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Start e-sign for a porting LOA (`send` emails the signer, `present` returns a URL).
|
|
53
|
+
*
|
|
54
|
+
* @param {Object} params
|
|
55
|
+
* @param {string} params.portingOrderId
|
|
56
|
+
* @param {string} params.signerName
|
|
57
|
+
* @param {string} params.mode - `send` or `present`
|
|
58
|
+
* @param {string} [params.signerTitle]
|
|
59
|
+
* @param {string} [params.signerEmail] - required when mode is send
|
|
60
|
+
* @returns {Promise<Object>} `{ packageId, status, signers, presentUrl?, presentExpiresAt? }`
|
|
61
|
+
*/
|
|
62
|
+
async generateLoa({
|
|
63
|
+
portingOrderId,
|
|
64
|
+
signerName,
|
|
65
|
+
signerTitle,
|
|
66
|
+
signerEmail,
|
|
67
|
+
mode,
|
|
68
|
+
}) {
|
|
69
|
+
this.sdk.validateParams(
|
|
70
|
+
{ portingOrderId, signerName, mode },
|
|
71
|
+
{
|
|
72
|
+
portingOrderId: { type: 'string', required: true },
|
|
73
|
+
signerName: { type: 'string', required: true },
|
|
74
|
+
mode: { type: 'string', required: true },
|
|
75
|
+
signerTitle: { type: 'string', required: false },
|
|
76
|
+
signerEmail: { type: 'string', required: false },
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const body = { signerName, mode };
|
|
81
|
+
if (signerTitle !== undefined) body.signerTitle = signerTitle;
|
|
82
|
+
if (signerEmail !== undefined) body.signerEmail = signerEmail;
|
|
83
|
+
|
|
84
|
+
const result = await internalRequest(
|
|
85
|
+
this.sdk,
|
|
86
|
+
`/phoneNumbers/porting/orders/${encodeURIComponent(
|
|
87
|
+
portingOrderId,
|
|
88
|
+
)}/generate-loa`,
|
|
89
|
+
'POST',
|
|
90
|
+
{ body },
|
|
91
|
+
);
|
|
92
|
+
return result;
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
async getPortingEvents(id, { page, limit } = {}) {
|
|
96
|
+
this.sdk.validateParams(
|
|
97
|
+
{ id },
|
|
98
|
+
{
|
|
99
|
+
id: { type: 'string', required: true },
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const params = new URLSearchParams();
|
|
104
|
+
if (page) params.append('page', page);
|
|
105
|
+
if (limit) params.append('limit', limit);
|
|
106
|
+
|
|
107
|
+
const queryString = params.toString();
|
|
108
|
+
const url = queryString
|
|
109
|
+
? `/phoneNumbers/porting/orders/${id}/events?${queryString}`
|
|
110
|
+
: `/phoneNumbers/porting/orders/${id}/events`;
|
|
111
|
+
|
|
112
|
+
const result = await internalRequest(this.sdk, url, 'GET');
|
|
113
|
+
return result;
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get available activation dates for a porting order
|
|
118
|
+
* - Creates the porting order in external system if not already created
|
|
119
|
+
* - Updates the order data to ensure it's current before fetching dates
|
|
120
|
+
* - Returns list of available activation dates for user selection
|
|
121
|
+
* - Validates that phone numbers and required order details are complete
|
|
122
|
+
* @param {string} id - Porting order ID
|
|
123
|
+
* @returns {Promise<Object>} Available activation dates and order status
|
|
124
|
+
* @example
|
|
125
|
+
* const dates = await sdk.phoneNumbers.getFocWindows("port_123...");
|
|
126
|
+
* // Returns:
|
|
127
|
+
* // {
|
|
128
|
+
* // id: "port_123...",
|
|
129
|
+
* // status: "draft",
|
|
130
|
+
* // availableDates: [
|
|
131
|
+
* // { date: "2025-08-30T00:00:00.000Z", type: "Standard", available: true },
|
|
132
|
+
* // { date: "2025-09-02T00:00:00.000Z", type: "Express", available: true }
|
|
133
|
+
* // ],
|
|
134
|
+
* // phoneNumbersCount: 1,
|
|
135
|
+
* // orderReady: true
|
|
136
|
+
* // }
|
|
137
|
+
*/
|
|
138
|
+
async getFocWindows(id) {
|
|
139
|
+
this.sdk.validateParams(
|
|
140
|
+
{ id },
|
|
141
|
+
{
|
|
142
|
+
id: { type: 'string', required: true },
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const result = await internalRequest(this.sdk,
|
|
147
|
+
`/phoneNumbers/porting/orders/${id}/foc-windows`,
|
|
148
|
+
'GET',
|
|
149
|
+
);
|
|
150
|
+
return result;
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Sync a porting order with the carrier
|
|
155
|
+
* Fetches the latest order details and comments from the carrier and updates the local database
|
|
156
|
+
* @param {string} id - Porting order ID
|
|
157
|
+
* @returns {Promise<Object>} Sync results including updates made and comments added
|
|
158
|
+
* @example
|
|
159
|
+
* const syncResult = await sdk.phoneNumbers.syncPortingOrder("port_123...");
|
|
160
|
+
* // Returns:
|
|
161
|
+
* // {
|
|
162
|
+
* // id: "port_123...",
|
|
163
|
+
* // carrierOrderId: "carrier_abc123",
|
|
164
|
+
* // orderUpdated: true,
|
|
165
|
+
* // commentsAdded: 2,
|
|
166
|
+
* // errors: []
|
|
167
|
+
* // }
|
|
168
|
+
*/
|
|
169
|
+
async syncPortingOrder(id) {
|
|
170
|
+
this.sdk.validateParams(
|
|
171
|
+
{ id },
|
|
172
|
+
{
|
|
173
|
+
id: { type: 'string', required: true },
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const result = await internalRequest(this.sdk,
|
|
178
|
+
`/phoneNumbers/porting/orders/${id}/sync`,
|
|
179
|
+
'POST',
|
|
180
|
+
);
|
|
181
|
+
return result;
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Mark a porting-order exception as resolved after the user has updated
|
|
186
|
+
* the order (documents, account number, etc.). Syncs with the carrier
|
|
187
|
+
* so local status picks up the next Telnyx state.
|
|
188
|
+
* @param {string} id - Porting order ID
|
|
189
|
+
* @param {string} exceptionId - Exception ID
|
|
190
|
+
* @param {Object} [options]
|
|
191
|
+
* @param {string} [options.resolution]
|
|
192
|
+
* @returns {Promise<Object>} Updated exception
|
|
193
|
+
*/
|
|
194
|
+
async resolvePortingException(id, exceptionId, { resolution } = {}) {
|
|
195
|
+
this.sdk.validateParams(
|
|
196
|
+
{ id, exceptionId },
|
|
197
|
+
{
|
|
198
|
+
id: { type: 'string', required: true },
|
|
199
|
+
exceptionId: { type: 'string', required: true },
|
|
200
|
+
},
|
|
201
|
+
);
|
|
202
|
+
const body = {};
|
|
203
|
+
if (resolution) body.resolution = resolution;
|
|
204
|
+
return internalRequest(
|
|
205
|
+
this.sdk,
|
|
206
|
+
`/phoneNumbers/porting/orders/${id}/exceptions/${exceptionId}/resolve`,
|
|
207
|
+
'POST',
|
|
208
|
+
{ body },
|
|
209
|
+
);
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get comments for a porting order
|
|
214
|
+
* @param {string} id - Porting order ID
|
|
215
|
+
* @param {Object} [options] - Query options
|
|
216
|
+
* @param {string} [options.includeInternal='true'] - Include internal comments ('true', 'false', 'only')
|
|
217
|
+
* @returns {Promise<Object>} Comments list with metadata
|
|
218
|
+
* @example
|
|
219
|
+
* // Get all comments
|
|
220
|
+
* const allComments = await sdk.phoneNumbers.getPortingComments("port_123...");
|
|
221
|
+
*
|
|
222
|
+
* // Get only public comments
|
|
223
|
+
* const publicComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'false' });
|
|
224
|
+
*
|
|
225
|
+
* // Get only internal comments
|
|
226
|
+
* const internalComments = await sdk.phoneNumbers.getPortingComments("port_123...", { includeInternal: 'only' });
|
|
227
|
+
*/
|
|
228
|
+
async getPortingComments(id, { includeInternal = 'true' } = {}) {
|
|
229
|
+
this.sdk.validateParams(
|
|
230
|
+
{ id },
|
|
231
|
+
{
|
|
232
|
+
id: { type: 'string', required: true },
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const params = new URLSearchParams();
|
|
237
|
+
if (includeInternal !== 'true') {
|
|
238
|
+
params.append('includeInternal', includeInternal);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const queryString = params.toString();
|
|
242
|
+
const url = `/phoneNumbers/porting/orders/${id}/comments${
|
|
243
|
+
queryString ? '?' + queryString : ''
|
|
244
|
+
}`;
|
|
245
|
+
|
|
246
|
+
const result = await internalRequest(this.sdk, url, 'GET');
|
|
247
|
+
return result;
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Post a comment on a porting order
|
|
252
|
+
* @param {string} id - Porting order ID
|
|
253
|
+
* @param {Object} params - Comment parameters
|
|
254
|
+
* @param {string} params.comment - Comment body text
|
|
255
|
+
* @param {boolean} [params.isInternal=false] - Whether this is an internal comment (not shared with carrier)
|
|
256
|
+
* @returns {Promise<Object>} Created comment details
|
|
257
|
+
* @example
|
|
258
|
+
* // Post a public comment (shared with carrier)
|
|
259
|
+
* const publicComment = await sdk.phoneNumbers.postPortingComment("port_123...", {
|
|
260
|
+
* comment: "Please expedite this port request",
|
|
261
|
+
* isInternal: false
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* // Post an internal comment (team use only)
|
|
265
|
+
* const internalComment = await sdk.phoneNumbers.postPortingComment("port_123...", {
|
|
266
|
+
* comment: "Customer called - they need this ASAP",
|
|
267
|
+
* isInternal: true
|
|
268
|
+
* });
|
|
269
|
+
*/
|
|
270
|
+
async postPortingComment(id, { comment, isInternal = false }) {
|
|
271
|
+
this.sdk.validateParams(
|
|
272
|
+
{ id, comment },
|
|
273
|
+
{
|
|
274
|
+
id: { type: 'string', required: true },
|
|
275
|
+
comment: { type: 'string', required: true },
|
|
276
|
+
isInternal: { type: 'boolean', required: false },
|
|
277
|
+
},
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
const result = await internalRequest(this.sdk,
|
|
281
|
+
`/phoneNumbers/porting/orders/${id}/comments`,
|
|
282
|
+
'POST',
|
|
283
|
+
{
|
|
284
|
+
body: { comment, isInternal },
|
|
285
|
+
},
|
|
286
|
+
);
|
|
287
|
+
return result;
|
|
288
|
+
},
|
|
289
|
+
};
|