@unboundcx/sdk 2.1.1 → 2.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
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",
@@ -85,4 +85,4 @@
85
85
  "registry": "https://registry.npmjs.org/",
86
86
  "access": "public"
87
87
  }
88
- }
88
+ }
@@ -19,16 +19,17 @@ export class LookupService {
19
19
  return result;
20
20
  }
21
21
 
22
- async lrn(phoneNumber) {
22
+ async lrn(phoneNumber, cnam = false) {
23
23
  this.sdk.validateParams(
24
- { phoneNumber },
24
+ { phoneNumber, cnam },
25
25
  {
26
26
  phoneNumber: { type: 'string', required: true },
27
+ cnam: { type: 'boolean', required: false },
27
28
  },
28
29
  );
29
30
 
30
31
  const params = {
31
- query: { phoneNumber },
32
+ query: { phoneNumber, cnam },
32
33
  };
33
34
 
34
35
  const result = await this.sdk._fetch('/lookup/lrn', 'GET', params);
@@ -196,6 +196,128 @@ export class PhoneNumbersService {
196
196
  const result = await this.sdk._fetch('/phoneNumbers/supported-countries', 'GET');
197
197
  return result;
198
198
  }
199
+
200
+ // Porting Methods
201
+ async checkPortability(phoneNumbers) {
202
+ this.sdk._validateRequired({ phoneNumbers }, ['phoneNumbers']);
203
+
204
+ if (!Array.isArray(phoneNumbers)) {
205
+ throw new Error('phoneNumbers must be an array');
206
+ }
207
+
208
+ const result = await this.sdk._fetch('/phoneNumbers/porting/portability-check', 'POST', {
209
+ phoneNumbers
210
+ });
211
+ return result;
212
+ }
213
+
214
+ async createPortingOrder({
215
+ phoneNumbers,
216
+ phoneNumberBlocks,
217
+ customerReference,
218
+ endUser,
219
+ activationSettings,
220
+ webhookUrl,
221
+ ...additionalData
222
+ }) {
223
+ if (!phoneNumbers && !phoneNumberBlocks) {
224
+ throw new Error('Either phoneNumbers or phoneNumberBlocks is required');
225
+ }
226
+
227
+ const body = {
228
+ ...additionalData
229
+ };
230
+
231
+ if (phoneNumbers) body.phoneNumbers = phoneNumbers;
232
+ if (phoneNumberBlocks) body.phoneNumberBlocks = phoneNumberBlocks;
233
+ if (customerReference) body.customerReference = customerReference;
234
+ if (endUser) body.endUser = endUser;
235
+ if (activationSettings) body.activationSettings = activationSettings;
236
+ if (webhookUrl) body.webhookUrl = webhookUrl;
237
+
238
+ const result = await this.sdk._fetch('/phoneNumbers/porting/orders', 'POST', body);
239
+ return result;
240
+ }
241
+
242
+ async getPortingOrders({
243
+ page,
244
+ includePhoneNumbers = true,
245
+ status,
246
+ customerReference,
247
+ sort,
248
+ limit
249
+ } = {}) {
250
+ const params = new URLSearchParams();
251
+
252
+ if (page) params.append('page', page);
253
+ if (includePhoneNumbers !== undefined) params.append('includePhoneNumbers', includePhoneNumbers);
254
+ if (status) params.append('status', status);
255
+ if (customerReference) params.append('customerReference', customerReference);
256
+ if (sort) params.append('sort', sort);
257
+ if (limit) params.append('limit', limit);
258
+
259
+ const queryString = params.toString();
260
+ const url = queryString ? `/phoneNumbers/porting/orders?${queryString}` : '/phoneNumbers/porting/orders';
261
+
262
+ const result = await this.sdk._fetch(url, 'GET');
263
+ return result;
264
+ }
265
+
266
+ async getPortingOrder(id, { includePhoneNumbers = true } = {}) {
267
+ this.sdk._validateRequired({ id }, ['id']);
268
+
269
+ const params = new URLSearchParams();
270
+ if (includePhoneNumbers !== undefined) params.append('includePhoneNumbers', includePhoneNumbers);
271
+
272
+ const queryString = params.toString();
273
+ const url = queryString ? `/phoneNumbers/porting/orders/${id}?${queryString}` : `/phoneNumbers/porting/orders/${id}`;
274
+
275
+ const result = await this.sdk._fetch(url, 'GET');
276
+ return result;
277
+ }
278
+
279
+ async updatePortingOrder(id, updateData) {
280
+ this.sdk._validateRequired({ id, updateData }, ['id', 'updateData']);
281
+
282
+ const result = await this.sdk._fetch(`/phoneNumbers/porting/orders/${id}`, 'PATCH', updateData);
283
+ return result;
284
+ }
285
+
286
+ async uploadPortingDocument({
287
+ filename,
288
+ fileContent,
289
+ contentType = 'application/pdf',
290
+ documentType = 'loa',
291
+ portingOrderId
292
+ }) {
293
+ this.sdk._validateRequired({ filename, fileContent }, ['filename', 'fileContent']);
294
+
295
+ const body = {
296
+ filename,
297
+ fileContent,
298
+ contentType,
299
+ documentType
300
+ };
301
+
302
+ if (portingOrderId) body.portingOrderId = portingOrderId;
303
+
304
+ const result = await this.sdk._fetch('/phoneNumbers/porting/documents', 'POST', body);
305
+ return result;
306
+ }
307
+
308
+ async getPortingEvents(id, { page, limit } = {}) {
309
+ this.sdk._validateRequired({ id }, ['id']);
310
+
311
+ const params = new URLSearchParams();
312
+ if (page) params.append('page', page);
313
+ if (limit) params.append('limit', limit);
314
+
315
+ const queryString = params.toString();
316
+ const url = queryString ? `/phoneNumbers/porting/orders/${id}/events?${queryString}` : `/phoneNumbers/porting/orders/${id}/events`;
317
+
318
+ const result = await this.sdk._fetch(url, 'GET');
319
+ return result;
320
+ }
199
321
  }
200
322
 
201
323
  export class PhoneNumberCarrierService {