@azure/communication-phone-numbers 1.3.0-alpha.20230517.1 → 1.3.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/README.md +4 -18
  2. package/dist/index.js +421 -593
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/generated/src/index.js +1 -0
  5. package/dist-esm/src/generated/src/index.js.map +1 -1
  6. package/dist-esm/src/generated/src/lroImpl.js +11 -15
  7. package/dist-esm/src/generated/src/lroImpl.js.map +1 -1
  8. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  9. package/dist-esm/src/generated/src/models/mappers.js +110 -0
  10. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  11. package/dist-esm/src/generated/src/models/parameters.js +6 -2
  12. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  13. package/dist-esm/src/generated/src/operations/phoneNumbers.js +155 -76
  14. package/dist-esm/src/generated/src/operations/phoneNumbers.js.map +1 -1
  15. package/dist-esm/src/generated/src/operationsInterfaces/phoneNumbers.js.map +1 -1
  16. package/dist-esm/src/generated/src/pagingHelper.js +32 -0
  17. package/dist-esm/src/generated/src/pagingHelper.js.map +1 -0
  18. package/dist-esm/src/generated/src/phoneNumbersClient.js +4 -22
  19. package/dist-esm/src/generated/src/phoneNumbersClient.js.map +1 -1
  20. package/dist-esm/src/generated/src/siprouting/models/index.js +1 -6
  21. package/dist-esm/src/generated/src/siprouting/models/index.js.map +1 -1
  22. package/dist-esm/src/generated/src/siprouting/models/mappers.js +0 -166
  23. package/dist-esm/src/generated/src/siprouting/models/mappers.js.map +1 -1
  24. package/dist-esm/src/generated/src/siprouting/models/parameters.js +2 -48
  25. package/dist-esm/src/generated/src/siprouting/models/parameters.js.map +1 -1
  26. package/dist-esm/src/generated/src/siprouting/operations/sipRouting.js +1 -35
  27. package/dist-esm/src/generated/src/siprouting/operations/sipRouting.js.map +1 -1
  28. package/dist-esm/src/generated/src/siprouting/operationsInterfaces/sipRouting.js.map +1 -1
  29. package/dist-esm/src/generated/src/siprouting/sipRoutingClientContext.js +2 -2
  30. package/dist-esm/src/generated/src/siprouting/sipRoutingClientContext.js.map +1 -1
  31. package/dist-esm/src/generated/src/tracing.js +1 -1
  32. package/dist-esm/src/generated/src/tracing.js.map +1 -1
  33. package/dist-esm/src/mappers.js +3 -31
  34. package/dist-esm/src/mappers.js.map +1 -1
  35. package/dist-esm/src/models.js.map +1 -1
  36. package/dist-esm/src/phoneNumbersClient.js +16 -3
  37. package/dist-esm/src/phoneNumbersClient.js.map +1 -1
  38. package/dist-esm/src/sipRoutingClient.js +63 -170
  39. package/dist-esm/src/sipRoutingClient.js.map +1 -1
  40. package/dist-esm/src/utils/constants.js +1 -1
  41. package/dist-esm/src/utils/constants.js.map +1 -1
  42. package/package.json +1 -2
  43. package/types/communication-phone-numbers.d.ts +53 -111
@@ -7,11 +7,12 @@
7
7
  */
8
8
  import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
9
9
  import { tracingClient } from "../tracing";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import * as coreClient from "@azure/core-client";
11
12
  import * as Mappers from "../models/mappers";
12
13
  import * as Parameters from "../models/parameters";
13
14
  import { LroEngine } from "@azure/core-lro";
14
- import { LroImpl } from "../lroImpl";
15
+ import { createLroSpec } from "../lroImpl";
15
16
  /// <reference lib="esnext.asynciterable" />
16
17
  /** Class containing PhoneNumbers operations. */
17
18
  export class PhoneNumbersImpl {
@@ -37,20 +38,31 @@ export class PhoneNumbersImpl {
37
38
  [Symbol.asyncIterator]() {
38
39
  return this;
39
40
  },
40
- byPage: () => {
41
- return this.listAreaCodesPagingPage(countryCode, phoneNumberType, options);
41
+ byPage: (settings) => {
42
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
43
+ throw new Error("maxPageSize is not supported by this operation.");
44
+ }
45
+ return this.listAreaCodesPagingPage(countryCode, phoneNumberType, options, settings);
42
46
  }
43
47
  };
44
48
  }
45
- listAreaCodesPagingPage(countryCode, phoneNumberType, options) {
49
+ listAreaCodesPagingPage(countryCode, phoneNumberType, options, settings) {
46
50
  return __asyncGenerator(this, arguments, function* listAreaCodesPagingPage_1() {
47
- let result = yield __await(this._listAreaCodes(countryCode, phoneNumberType, options));
48
- yield yield __await(result.areaCodes || []);
49
- let continuationToken = result.nextLink;
51
+ let result;
52
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
53
+ if (!continuationToken) {
54
+ result = yield __await(this._listAreaCodes(countryCode, phoneNumberType, options));
55
+ let page = result.areaCodes || [];
56
+ continuationToken = result.nextLink;
57
+ setContinuationToken(page, continuationToken);
58
+ yield yield __await(page);
59
+ }
50
60
  while (continuationToken) {
51
- result = yield __await(this._listAreaCodesNext(countryCode, phoneNumberType, continuationToken, options));
61
+ result = yield __await(this._listAreaCodesNext(countryCode, continuationToken, options));
52
62
  continuationToken = result.nextLink;
53
- yield yield __await(result.areaCodes || []);
63
+ let page = result.areaCodes || [];
64
+ setContinuationToken(page, continuationToken);
65
+ yield yield __await(page);
54
66
  }
55
67
  });
56
68
  }
@@ -92,20 +104,31 @@ export class PhoneNumbersImpl {
92
104
  [Symbol.asyncIterator]() {
93
105
  return this;
94
106
  },
95
- byPage: () => {
96
- return this.listAvailableCountriesPagingPage(options);
107
+ byPage: (settings) => {
108
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
109
+ throw new Error("maxPageSize is not supported by this operation.");
110
+ }
111
+ return this.listAvailableCountriesPagingPage(options, settings);
97
112
  }
98
113
  };
99
114
  }
100
- listAvailableCountriesPagingPage(options) {
115
+ listAvailableCountriesPagingPage(options, settings) {
101
116
  return __asyncGenerator(this, arguments, function* listAvailableCountriesPagingPage_1() {
102
- let result = yield __await(this._listAvailableCountries(options));
103
- yield yield __await(result.countries || []);
104
- let continuationToken = result.nextLink;
117
+ let result;
118
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
119
+ if (!continuationToken) {
120
+ result = yield __await(this._listAvailableCountries(options));
121
+ let page = result.countries || [];
122
+ continuationToken = result.nextLink;
123
+ setContinuationToken(page, continuationToken);
124
+ yield yield __await(page);
125
+ }
105
126
  while (continuationToken) {
106
127
  result = yield __await(this._listAvailableCountriesNext(continuationToken, options));
107
128
  continuationToken = result.nextLink;
108
- yield yield __await(result.countries || []);
129
+ let page = result.countries || [];
130
+ setContinuationToken(page, continuationToken);
131
+ yield yield __await(page);
109
132
  }
110
133
  });
111
134
  }
@@ -148,20 +171,31 @@ export class PhoneNumbersImpl {
148
171
  [Symbol.asyncIterator]() {
149
172
  return this;
150
173
  },
151
- byPage: () => {
152
- return this.listAvailableLocalitiesPagingPage(countryCode, options);
174
+ byPage: (settings) => {
175
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
176
+ throw new Error("maxPageSize is not supported by this operation.");
177
+ }
178
+ return this.listAvailableLocalitiesPagingPage(countryCode, options, settings);
153
179
  }
154
180
  };
155
181
  }
156
- listAvailableLocalitiesPagingPage(countryCode, options) {
182
+ listAvailableLocalitiesPagingPage(countryCode, options, settings) {
157
183
  return __asyncGenerator(this, arguments, function* listAvailableLocalitiesPagingPage_1() {
158
- let result = yield __await(this._listAvailableLocalities(countryCode, options));
159
- yield yield __await(result.phoneNumberLocalities || []);
160
- let continuationToken = result.nextLink;
184
+ let result;
185
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
186
+ if (!continuationToken) {
187
+ result = yield __await(this._listAvailableLocalities(countryCode, options));
188
+ let page = result.phoneNumberLocalities || [];
189
+ continuationToken = result.nextLink;
190
+ setContinuationToken(page, continuationToken);
191
+ yield yield __await(page);
192
+ }
161
193
  while (continuationToken) {
162
194
  result = yield __await(this._listAvailableLocalitiesNext(countryCode, continuationToken, options));
163
195
  continuationToken = result.nextLink;
164
- yield yield __await(result.phoneNumberLocalities || []);
196
+ let page = result.phoneNumberLocalities || [];
197
+ setContinuationToken(page, continuationToken);
198
+ yield yield __await(page);
165
199
  }
166
200
  });
167
201
  }
@@ -204,20 +238,31 @@ export class PhoneNumbersImpl {
204
238
  [Symbol.asyncIterator]() {
205
239
  return this;
206
240
  },
207
- byPage: () => {
208
- return this.listOfferingsPagingPage(countryCode, options);
241
+ byPage: (settings) => {
242
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
243
+ throw new Error("maxPageSize is not supported by this operation.");
244
+ }
245
+ return this.listOfferingsPagingPage(countryCode, options, settings);
209
246
  }
210
247
  };
211
248
  }
212
- listOfferingsPagingPage(countryCode, options) {
249
+ listOfferingsPagingPage(countryCode, options, settings) {
213
250
  return __asyncGenerator(this, arguments, function* listOfferingsPagingPage_1() {
214
- let result = yield __await(this._listOfferings(countryCode, options));
215
- yield yield __await(result.phoneNumberOfferings || []);
216
- let continuationToken = result.nextLink;
251
+ let result;
252
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
253
+ if (!continuationToken) {
254
+ result = yield __await(this._listOfferings(countryCode, options));
255
+ let page = result.phoneNumberOfferings || [];
256
+ continuationToken = result.nextLink;
257
+ setContinuationToken(page, continuationToken);
258
+ yield yield __await(page);
259
+ }
217
260
  while (continuationToken) {
218
261
  result = yield __await(this._listOfferingsNext(countryCode, continuationToken, options));
219
262
  continuationToken = result.nextLink;
220
- yield yield __await(result.phoneNumberOfferings || []);
263
+ let page = result.phoneNumberOfferings || [];
264
+ setContinuationToken(page, continuationToken);
265
+ yield yield __await(page);
221
266
  }
222
267
  });
223
268
  }
@@ -259,20 +304,31 @@ export class PhoneNumbersImpl {
259
304
  [Symbol.asyncIterator]() {
260
305
  return this;
261
306
  },
262
- byPage: () => {
263
- return this.listPhoneNumbersPagingPage(options);
307
+ byPage: (settings) => {
308
+ if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
309
+ throw new Error("maxPageSize is not supported by this operation.");
310
+ }
311
+ return this.listPhoneNumbersPagingPage(options, settings);
264
312
  }
265
313
  };
266
314
  }
267
- listPhoneNumbersPagingPage(options) {
315
+ listPhoneNumbersPagingPage(options, settings) {
268
316
  return __asyncGenerator(this, arguments, function* listPhoneNumbersPagingPage_1() {
269
- let result = yield __await(this._listPhoneNumbers(options));
270
- yield yield __await(result.phoneNumbers || []);
271
- let continuationToken = result.nextLink;
317
+ let result;
318
+ let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
319
+ if (!continuationToken) {
320
+ result = yield __await(this._listPhoneNumbers(options));
321
+ let page = result.phoneNumbers || [];
322
+ continuationToken = result.nextLink;
323
+ setContinuationToken(page, continuationToken);
324
+ yield yield __await(page);
325
+ }
272
326
  while (continuationToken) {
273
327
  result = yield __await(this._listPhoneNumbersNext(continuationToken, options));
274
328
  continuationToken = result.nextLink;
275
- yield yield __await(result.phoneNumbers || []);
329
+ let page = result.phoneNumbers || [];
330
+ setContinuationToken(page, continuationToken);
331
+ yield yield __await(page);
276
332
  }
277
333
  });
278
334
  }
@@ -356,7 +412,7 @@ export class PhoneNumbersImpl {
356
412
  return this.client.sendOperationRequest(args, spec);
357
413
  });
358
414
  };
359
- const sendOperation = async (args, spec) => {
415
+ const sendOperationFn = async (args, spec) => {
360
416
  var _a;
361
417
  let currentRawResponse = undefined;
362
418
  const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
@@ -375,7 +431,17 @@ export class PhoneNumbersImpl {
375
431
  }
376
432
  };
377
433
  };
378
- const lro = new LroImpl(sendOperation, { countryCode, phoneNumberType, assignmentType, capabilities, options }, searchAvailablePhoneNumbersOperationSpec);
434
+ const lro = createLroSpec({
435
+ sendOperationFn,
436
+ args: {
437
+ countryCode,
438
+ phoneNumberType,
439
+ assignmentType,
440
+ capabilities,
441
+ options
442
+ },
443
+ spec: searchAvailablePhoneNumbersOperationSpec
444
+ });
379
445
  const poller = new LroEngine(lro, {
380
446
  resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
381
447
  intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs,
@@ -417,7 +483,7 @@ export class PhoneNumbersImpl {
417
483
  return this.client.sendOperationRequest(args, spec);
418
484
  });
419
485
  };
420
- const sendOperation = async (args, spec) => {
486
+ const sendOperationFn = async (args, spec) => {
421
487
  var _a;
422
488
  let currentRawResponse = undefined;
423
489
  const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
@@ -436,7 +502,11 @@ export class PhoneNumbersImpl {
436
502
  }
437
503
  };
438
504
  };
439
- const lro = new LroImpl(sendOperation, { options }, purchasePhoneNumbersOperationSpec);
505
+ const lro = createLroSpec({
506
+ sendOperationFn,
507
+ args: { options },
508
+ spec: purchasePhoneNumbersOperationSpec
509
+ });
440
510
  const poller = new LroEngine(lro, {
441
511
  resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
442
512
  intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs
@@ -484,7 +554,7 @@ export class PhoneNumbersImpl {
484
554
  return this.client.sendOperationRequest(args, spec);
485
555
  });
486
556
  };
487
- const sendOperation = async (args, spec) => {
557
+ const sendOperationFn = async (args, spec) => {
488
558
  var _a;
489
559
  let currentRawResponse = undefined;
490
560
  const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
@@ -503,7 +573,11 @@ export class PhoneNumbersImpl {
503
573
  }
504
574
  };
505
575
  };
506
- const lro = new LroImpl(sendOperation, { phoneNumber, options }, updateCapabilitiesOperationSpec);
576
+ const lro = createLroSpec({
577
+ sendOperationFn,
578
+ args: { phoneNumber, options },
579
+ spec: updateCapabilitiesOperationSpec
580
+ });
507
581
  const poller = new LroEngine(lro, {
508
582
  resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
509
583
  intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs,
@@ -544,7 +618,7 @@ export class PhoneNumbersImpl {
544
618
  return this.client.sendOperationRequest(args, spec);
545
619
  });
546
620
  };
547
- const sendOperation = async (args, spec) => {
621
+ const sendOperationFn = async (args, spec) => {
548
622
  var _a;
549
623
  let currentRawResponse = undefined;
550
624
  const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
@@ -563,7 +637,11 @@ export class PhoneNumbersImpl {
563
637
  }
564
638
  };
565
639
  };
566
- const lro = new LroImpl(sendOperation, { phoneNumber, options }, releasePhoneNumberOperationSpec);
640
+ const lro = createLroSpec({
641
+ sendOperationFn,
642
+ args: { phoneNumber, options },
643
+ spec: releasePhoneNumberOperationSpec
644
+ });
567
645
  const poller = new LroEngine(lro, {
568
646
  resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
569
647
  intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs
@@ -589,16 +667,24 @@ export class PhoneNumbersImpl {
589
667
  return this.client.sendOperationRequest({ options }, listPhoneNumbersOperationSpec);
590
668
  });
591
669
  }
670
+ /**
671
+ * Searches for operator information for a given list of phone numbers.
672
+ * @param options The options parameters.
673
+ */
674
+ async operatorInformationSearch(options) {
675
+ return tracingClient.withSpan("PhoneNumbersClient.operatorInformationSearch", options !== null && options !== void 0 ? options : {}, async (options) => {
676
+ return this.client.sendOperationRequest({ options }, operatorInformationSearchOperationSpec);
677
+ });
678
+ }
592
679
  /**
593
680
  * ListAreaCodesNext
594
681
  * @param countryCode The ISO 3166-2 country code, e.g. US.
595
- * @param phoneNumberType Filter by numberType, e.g. Geographic, TollFree.
596
682
  * @param nextLink The nextLink from the previous successful call to the ListAreaCodes method.
597
683
  * @param options The options parameters.
598
684
  */
599
- async _listAreaCodesNext(countryCode, phoneNumberType, nextLink, options) {
685
+ async _listAreaCodesNext(countryCode, nextLink, options) {
600
686
  return tracingClient.withSpan("PhoneNumbersClient._listAreaCodesNext", options !== null && options !== void 0 ? options : {}, async (options) => {
601
- return this.client.sendOperationRequest({ countryCode, phoneNumberType, nextLink, options }, listAreaCodesNextOperationSpec);
687
+ return this.client.sendOperationRequest({ countryCode, nextLink, options }, listAreaCodesNextOperationSpec);
602
688
  });
603
689
  }
604
690
  /**
@@ -942,6 +1028,27 @@ const listPhoneNumbersOperationSpec = {
942
1028
  headerParameters: [Parameters.accept],
943
1029
  serializer
944
1030
  };
1031
+ const operatorInformationSearchOperationSpec = {
1032
+ path: "/operatorInformation/:search",
1033
+ httpMethod: "POST",
1034
+ responses: {
1035
+ 200: {
1036
+ bodyMapper: Mappers.OperatorInformationResult
1037
+ },
1038
+ default: {
1039
+ bodyMapper: Mappers.CommunicationErrorResponse
1040
+ }
1041
+ },
1042
+ requestBody: {
1043
+ parameterPath: { phoneNumbers: ["options", "phoneNumbers"] },
1044
+ mapper: Object.assign(Object.assign({}, Mappers.OperatorInformationRequest), { required: true })
1045
+ },
1046
+ queryParameters: [Parameters.apiVersion],
1047
+ urlParameters: [Parameters.endpoint],
1048
+ headerParameters: [Parameters.accept, Parameters.contentType],
1049
+ mediaType: "json",
1050
+ serializer
1051
+ };
945
1052
  const listAreaCodesNextOperationSpec = {
946
1053
  path: "{nextLink}",
947
1054
  httpMethod: "GET",
@@ -953,15 +1060,6 @@ const listAreaCodesNextOperationSpec = {
953
1060
  bodyMapper: Mappers.CommunicationErrorResponse
954
1061
  }
955
1062
  },
956
- queryParameters: [
957
- Parameters.phoneNumberType,
958
- Parameters.skip,
959
- Parameters.maxPageSize,
960
- Parameters.assignmentType,
961
- Parameters.locality,
962
- Parameters.administrativeDivision,
963
- Parameters.apiVersion
964
- ],
965
1063
  urlParameters: [
966
1064
  Parameters.endpoint,
967
1065
  Parameters.countryCode,
@@ -981,11 +1079,6 @@ const listAvailableCountriesNextOperationSpec = {
981
1079
  bodyMapper: Mappers.CommunicationErrorResponse
982
1080
  }
983
1081
  },
984
- queryParameters: [
985
- Parameters.skip,
986
- Parameters.maxPageSize,
987
- Parameters.apiVersion
988
- ],
989
1082
  urlParameters: [Parameters.endpoint, Parameters.nextLink],
990
1083
  headerParameters: [Parameters.accept, Parameters.acceptLanguage],
991
1084
  serializer
@@ -1001,12 +1094,6 @@ const listAvailableLocalitiesNextOperationSpec = {
1001
1094
  bodyMapper: Mappers.CommunicationErrorResponse
1002
1095
  }
1003
1096
  },
1004
- queryParameters: [
1005
- Parameters.skip,
1006
- Parameters.maxPageSize,
1007
- Parameters.administrativeDivision,
1008
- Parameters.apiVersion
1009
- ],
1010
1097
  urlParameters: [
1011
1098
  Parameters.endpoint,
1012
1099
  Parameters.countryCode,
@@ -1026,13 +1113,6 @@ const listOfferingsNextOperationSpec = {
1026
1113
  bodyMapper: Mappers.CommunicationErrorResponse
1027
1114
  }
1028
1115
  },
1029
- queryParameters: [
1030
- Parameters.skip,
1031
- Parameters.maxPageSize,
1032
- Parameters.assignmentType,
1033
- Parameters.apiVersion,
1034
- Parameters.phoneNumberType1
1035
- ],
1036
1116
  urlParameters: [
1037
1117
  Parameters.endpoint,
1038
1118
  Parameters.countryCode,
@@ -1052,7 +1132,6 @@ const listPhoneNumbersNextOperationSpec = {
1052
1132
  bodyMapper: Mappers.CommunicationErrorResponse
1053
1133
  }
1054
1134
  },
1055
- queryParameters: [Parameters.skip, Parameters.apiVersion, Parameters.top],
1056
1135
  urlParameters: [Parameters.endpoint, Parameters.nextLink],
1057
1136
  headerParameters: [Parameters.accept],
1058
1137
  serializer