@azure/communication-phone-numbers 1.3.0-alpha.20250122.2 → 1.3.0-alpha.20250127.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +165 -186
- package/dist/browser/generated/src/lroImpl.d.ts.map +1 -1
- package/dist/browser/generated/src/lroImpl.js +0 -7
- package/dist/browser/generated/src/lroImpl.js.map +1 -1
- package/dist/browser/phoneNumbersClient.d.ts +141 -50
- package/dist/browser/phoneNumbersClient.d.ts.map +1 -1
- package/dist/browser/phoneNumbersClient.js +141 -50
- package/dist/browser/phoneNumbersClient.js.map +1 -1
- package/dist/commonjs/generated/src/lroImpl.d.ts.map +1 -1
- package/dist/commonjs/generated/src/lroImpl.js +0 -7
- package/dist/commonjs/generated/src/lroImpl.js.map +1 -1
- package/dist/commonjs/phoneNumbersClient.d.ts +141 -50
- package/dist/commonjs/phoneNumbersClient.d.ts.map +1 -1
- package/dist/commonjs/phoneNumbersClient.js +141 -50
- package/dist/commonjs/phoneNumbersClient.js.map +1 -1
- package/dist/esm/generated/src/lroImpl.d.ts.map +1 -1
- package/dist/esm/generated/src/lroImpl.js +0 -7
- package/dist/esm/generated/src/lroImpl.js.map +1 -1
- package/dist/esm/phoneNumbersClient.d.ts +141 -50
- package/dist/esm/phoneNumbersClient.d.ts.map +1 -1
- package/dist/esm/phoneNumbersClient.js +141 -50
- package/dist/esm/phoneNumbersClient.js.map +1 -1
- package/dist/react-native/generated/src/lroImpl.d.ts.map +1 -1
- package/dist/react-native/generated/src/lroImpl.js +0 -7
- package/dist/react-native/generated/src/lroImpl.js.map +1 -1
- package/dist/react-native/phoneNumbersClient.d.ts +141 -50
- package/dist/react-native/phoneNumbersClient.d.ts.map +1 -1
- package/dist/react-native/phoneNumbersClient.js +141 -50
- package/dist/react-native/phoneNumbersClient.js.map +1 -1
- package/package.json +16 -16
@@ -47,10 +47,18 @@ export class PhoneNumbersClient {
|
|
47
47
|
* Iterates the purchased phone numbers.
|
48
48
|
*
|
49
49
|
* Example usage:
|
50
|
-
* ```ts
|
51
|
-
*
|
52
|
-
*
|
53
|
-
*
|
50
|
+
* ```ts snippet:PhoneNumbersClientListPurchasedPhoneNumbers
|
51
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
52
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
53
|
+
*
|
54
|
+
* const credential = new DefaultAzureCredential();
|
55
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
56
|
+
*
|
57
|
+
* const phoneNumbers = client.listPurchasedPhoneNumbers();
|
58
|
+
*
|
59
|
+
* for await (const phoneNumber of phoneNumbers) {
|
60
|
+
* console.log(`The id is the same as the phone number: ${phoneNumber.id}`);
|
61
|
+
* console.log(`Phone number type is ${phoneNumber.phoneNumberType}`);
|
54
62
|
* }
|
55
63
|
* ```
|
56
64
|
* List all purchased phone numbers.
|
@@ -78,16 +86,20 @@ export class PhoneNumbersClient {
|
|
78
86
|
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.
|
79
87
|
*
|
80
88
|
* Example usage:
|
81
|
-
* ```ts
|
82
|
-
*
|
83
|
-
*
|
89
|
+
* ```ts snippet:PhoneNumbersClientReleasePhoneNumber
|
90
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
91
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
84
92
|
*
|
85
|
-
*
|
86
|
-
* const
|
93
|
+
* const credential = new DefaultAzureCredential();
|
94
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
87
95
|
*
|
88
|
-
*
|
89
|
-
*
|
90
|
-
*
|
96
|
+
* const phoneNumberToRelease = "<phone-number-to-release>";
|
97
|
+
*
|
98
|
+
* const releasePoller = await client.beginReleasePhoneNumber(phoneNumberToRelease);
|
99
|
+
*
|
100
|
+
* // Release is underway.
|
101
|
+
* await releasePoller.pollUntilDone();
|
102
|
+
* console.log("Successfully release phone number.");
|
91
103
|
* ```
|
92
104
|
* @param phoneNumber - The E.164 formatted phone number being released. The leading plus can be either + or encoded as %2B.
|
93
105
|
* @param options - Additional request options.
|
@@ -104,16 +116,33 @@ export class PhoneNumbersClient {
|
|
104
116
|
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.
|
105
117
|
*
|
106
118
|
* Example usage:
|
107
|
-
* ```ts
|
108
|
-
*
|
109
|
-
*
|
119
|
+
* ```ts snippet:PhoneNumbersClientSearchAvailablePhoneNumbers
|
120
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
121
|
+
* import {
|
122
|
+
* PhoneNumbersClient,
|
123
|
+
* SearchAvailablePhoneNumbersRequest,
|
124
|
+
* } from "@azure/communication-phone-numbers";
|
125
|
+
*
|
126
|
+
* const credential = new DefaultAzureCredential();
|
127
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
110
128
|
*
|
111
|
-
*
|
112
|
-
*
|
129
|
+
* const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
130
|
+
* countryCode: "US",
|
131
|
+
* phoneNumberType: "tollFree",
|
132
|
+
* assignmentType: "application",
|
133
|
+
* capabilities: {
|
134
|
+
* sms: "outbound",
|
135
|
+
* calling: "none",
|
136
|
+
* },
|
137
|
+
* quantity: 1,
|
138
|
+
* };
|
113
139
|
*
|
114
|
-
*
|
115
|
-
*
|
116
|
-
*
|
140
|
+
* const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
141
|
+
*
|
142
|
+
* // The search is underway. Wait to receive searchId.
|
143
|
+
* const searchResults = await searchPoller.pollUntilDone();
|
144
|
+
* console.log(`Found phone number: ${searchResults.phoneNumbers[0]}`);
|
145
|
+
* console.log(`searchId: ${searchResults.searchId}`);
|
117
146
|
* ```
|
118
147
|
*
|
119
148
|
* @param search - Request properties to constraint the search scope.
|
@@ -131,16 +160,37 @@ export class PhoneNumbersClient {
|
|
131
160
|
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.
|
132
161
|
*
|
133
162
|
* Example usage:
|
134
|
-
* ```ts
|
135
|
-
*
|
136
|
-
*
|
163
|
+
* ```ts snippet:PhoneNumbersClientPurchasePhoneNumbers
|
164
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
165
|
+
* import {
|
166
|
+
* PhoneNumbersClient,
|
167
|
+
* SearchAvailablePhoneNumbersRequest,
|
168
|
+
* } from "@azure/communication-phone-numbers";
|
169
|
+
*
|
170
|
+
* const credential = new DefaultAzureCredential();
|
171
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
172
|
+
*
|
173
|
+
* const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
174
|
+
* countryCode: "US",
|
175
|
+
* phoneNumberType: "tollFree",
|
176
|
+
* assignmentType: "application",
|
177
|
+
* capabilities: {
|
178
|
+
* sms: "outbound",
|
179
|
+
* calling: "none",
|
180
|
+
* },
|
181
|
+
* quantity: 1,
|
182
|
+
* };
|
137
183
|
*
|
138
|
-
*
|
139
|
-
* const serialized = purchasePoller.toString();
|
184
|
+
* const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
140
185
|
*
|
141
|
-
* //
|
142
|
-
* const
|
143
|
-
*
|
186
|
+
* // The search is underway. Wait to receive searchId.
|
187
|
+
* const { searchId, phoneNumbers } = await searchPoller.pollUntilDone();
|
188
|
+
*
|
189
|
+
* const purchasePoller = await client.beginPurchasePhoneNumbers(searchId);
|
190
|
+
*
|
191
|
+
* // Purchase is underway.
|
192
|
+
* await purchasePoller.pollUntilDone();
|
193
|
+
* console.log(`Successfully purchased ${phoneNumbers[0]}`);
|
144
194
|
* ```
|
145
195
|
*
|
146
196
|
* @param searchId - The id of the search to purchase. Returned from `beginSearchAvailablePhoneNumbers`
|
@@ -157,16 +207,32 @@ export class PhoneNumbersClient {
|
|
157
207
|
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.
|
158
208
|
*
|
159
209
|
* Example usage:
|
160
|
-
* ```ts
|
161
|
-
*
|
162
|
-
*
|
210
|
+
* ```ts snippet:PhoneNumbersClientUpdatePhoneNumberCapabilities
|
211
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
212
|
+
* import {
|
213
|
+
* PhoneNumbersClient,
|
214
|
+
* PhoneNumberCapabilitiesRequest,
|
215
|
+
* } from "@azure/communication-phone-numbers";
|
216
|
+
*
|
217
|
+
* const credential = new DefaultAzureCredential();
|
218
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
163
219
|
*
|
164
|
-
*
|
165
|
-
* const serialized = updatePoller.toString();
|
220
|
+
* const phoneNumberToUpdate = "<phone-number-to-update>";
|
166
221
|
*
|
167
|
-
* //
|
168
|
-
* const
|
169
|
-
*
|
222
|
+
* // This will update phone number to send and receive sms, but only send calls.
|
223
|
+
* const updateRequest: PhoneNumberCapabilitiesRequest = {
|
224
|
+
* sms: "inbound+outbound",
|
225
|
+
* calling: "outbound",
|
226
|
+
* };
|
227
|
+
*
|
228
|
+
* const updatePoller = await client.beginUpdatePhoneNumberCapabilities(
|
229
|
+
* phoneNumberToUpdate,
|
230
|
+
* updateRequest,
|
231
|
+
* );
|
232
|
+
*
|
233
|
+
* // Update is underway.
|
234
|
+
* const { capabilities } = await updatePoller.pollUntilDone();
|
235
|
+
* console.log(`These are the update capabilities: ${capabilities}`);
|
170
236
|
* ```
|
171
237
|
*
|
172
238
|
* @param phoneNumber - The E.164 formatted phone number being updated. The leading plus can be either + or encoded as %2B.
|
@@ -185,8 +251,13 @@ export class PhoneNumbersClient {
|
|
185
251
|
* Iterates the available countries.
|
186
252
|
*
|
187
253
|
* Example usage:
|
188
|
-
* ```ts
|
189
|
-
*
|
254
|
+
* ```ts snippet:PhoneNumbersClientListAvailableCountries
|
255
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
256
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
257
|
+
*
|
258
|
+
* const credential = new DefaultAzureCredential();
|
259
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
260
|
+
*
|
190
261
|
* for await (const country of client.listAvailableCountries()) {
|
191
262
|
* console.log("country: ", country.localizedName);
|
192
263
|
* }
|
@@ -214,9 +285,14 @@ export class PhoneNumbersClient {
|
|
214
285
|
* Iterates the available Toll-Free area codes.
|
215
286
|
*
|
216
287
|
* Example usage:
|
217
|
-
* ```ts
|
218
|
-
*
|
219
|
-
*
|
288
|
+
* ```ts snippet:PhoneNumbersClientListTollFreeAreaCodes
|
289
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
290
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
291
|
+
*
|
292
|
+
* const credential = new DefaultAzureCredential();
|
293
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
294
|
+
*
|
295
|
+
* for await (const areaCodeItem of client.listAvailableTollFreeAreaCodes("US")) {
|
220
296
|
* console.log("area code: ", areaCodeItem.areaCode);
|
221
297
|
* }
|
222
298
|
* ```
|
@@ -244,9 +320,14 @@ export class PhoneNumbersClient {
|
|
244
320
|
* Iterates the available Geographic area codes.
|
245
321
|
*
|
246
322
|
* Example usage:
|
247
|
-
* ```ts
|
248
|
-
*
|
249
|
-
*
|
323
|
+
* ```ts snippet:PhoneNumbersClientListGeographicAreaCodes
|
324
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
325
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
326
|
+
*
|
327
|
+
* const credential = new DefaultAzureCredential();
|
328
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
329
|
+
*
|
330
|
+
* for await (const areaCodeItem of client.listAvailableGeographicAreaCodes("US")) {
|
250
331
|
* console.log("area code: ", areaCodeItem.areaCode);
|
251
332
|
* }
|
252
333
|
* ```
|
@@ -274,9 +355,14 @@ export class PhoneNumbersClient {
|
|
274
355
|
* Iterates the available localities.
|
275
356
|
*
|
276
357
|
* Example usage:
|
277
|
-
* ```ts
|
278
|
-
*
|
279
|
-
*
|
358
|
+
* ```ts snippet:PhoneNumbersClientListAvailableLocalities
|
359
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
360
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
361
|
+
*
|
362
|
+
* const credential = new DefaultAzureCredential();
|
363
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
364
|
+
*
|
365
|
+
* for await (const locality of client.listAvailableLocalities("US")) {
|
280
366
|
* console.log("locality: ", locality.localizedName);
|
281
367
|
* }
|
282
368
|
* ```
|
@@ -304,9 +390,14 @@ export class PhoneNumbersClient {
|
|
304
390
|
* Iterates the available offerings.
|
305
391
|
*
|
306
392
|
* Example usage:
|
307
|
-
* ```ts
|
308
|
-
*
|
309
|
-
*
|
393
|
+
* ```ts snippet:PhoneNumbersClientListAvailableOfferings
|
394
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
395
|
+
* import { PhoneNumbersClient } from "@azure/communication-phone-numbers";
|
396
|
+
*
|
397
|
+
* const credential = new DefaultAzureCredential();
|
398
|
+
* const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);
|
399
|
+
*
|
400
|
+
* for await (const offering of client.listAvailableOfferings("US")) {
|
310
401
|
* console.log("phone number type: ", offering.phoneNumberType);
|
311
402
|
* console.log("cost: ", offering.cost.amount);
|
312
403
|
* }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"phoneNumbersClient.js","sourceRoot":"","sources":["../../src/phoneNumbersClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;AAE5C,uDAAuD;AACvD,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AA8B7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EAAE,MAAM,E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,gCAAgC,EAAE,KAAK,EAAE;QAEvF,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,8CAA8C,EAC9C,OAAO,CACR,CAAC;QAEF,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,yBAAyB,CAAC,YAAY,kCACjE,cAAc,KACjB,OAAO,EAAE,EAAE,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,EAAE,IACvF,CAAC;QACL,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;YAEH,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/// <reference lib=\"esnext.asynciterable\" />\n\n/* eslint-disable @azure/azure-sdk/ts-naming-options */\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport type { PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { PhoneNumbersClient as PhoneNumbersGeneratedClient } from \"./generated/src/index.js\";\nimport type {\n OperatorInformationResult,\n PhoneNumberAreaCode,\n PhoneNumberCapabilitiesRequest,\n PhoneNumberCountry,\n PhoneNumberLocality,\n PhoneNumberOffering,\n PhoneNumberSearchResult,\n PurchasedPhoneNumber,\n} from \"./generated/src/models/index.js\";\nimport type {\n GetPurchasedPhoneNumberOptions,\n ListAvailableCountriesOptions,\n ListGeographicAreaCodesOptions,\n ListLocalitiesOptions,\n ListOfferingsOptions,\n ListPurchasedPhoneNumbersOptions,\n ListTollFreeAreaCodesOptions,\n PurchasePhoneNumbersResult,\n ReleasePhoneNumberResult,\n SearchAvailablePhoneNumbersRequest,\n SearchOperatorInformationOptions,\n} from \"./models.js\";\nimport type {\n BeginPurchasePhoneNumbersOptions,\n BeginReleasePhoneNumberOptions,\n BeginSearchAvailablePhoneNumbersOptions,\n BeginUpdatePhoneNumberCapabilitiesOptions,\n} from \"./lroModels.js\";\nimport { createPhoneNumbersPagingPolicy } from \"./utils/customPipelinePolicies.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { logger } from \"./utils/index.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\n/**\n * Client options used to configure the PhoneNumbersClient API requests.\n */\nexport interface PhoneNumbersClientOptions extends CommonClientOptions {\n /**\n * The accept language parameter to be used in the request header's \"accept-language\" property.\n */\n acceptLanguage?: string;\n}\n\nconst isPhoneNumbersClientOptions = (options: any): options is PhoneNumbersClientOptions =>\n options && !isKeyCredential(options) && !isTokenCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services Phone Number Administration.\n */\nexport class PhoneNumbersClient {\n /**\n * A reference to the auto-generated PhoneNumber HTTP client.\n */\n private readonly client: PhoneNumbersGeneratedClient;\n\n /**\n * The accept language parameter to be used in the request header's \"accept-language\" property.\n */\n private acceptLanguage: string | undefined;\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using a connection string.\n *\n * @param connectionString - Connection string to connect to an Azure Communication Service resource. (eg: endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret)\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: PhoneNumbersClientOptions);\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using an Azure KeyCredential.\n *\n * @param url - The endpoint of the service (eg: https://contoso.eastus.communications.azure.net)\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(url: string, credential: KeyCredential, options?: PhoneNumbersClientOptions);\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using a TokenCredential.\n * @param url - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(url: string, credential: TokenCredential, options?: PhoneNumbersClientOptions);\n\n public constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | PhoneNumbersClientOptions,\n maybeOptions: PhoneNumbersClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isPhoneNumbersClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new PhoneNumbersGeneratedClient(url, {\n endpoint: url,\n ...internalPipelineOptions,\n });\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n\n // This policy is temporary workarounds to address compatibility issues with Azure Core V2.\n const phoneNumbersPagingPolicy = createPhoneNumbersPagingPolicy(url);\n this.client.pipeline.addPolicy(phoneNumbersPagingPolicy);\n this.acceptLanguage = maybeOptions.acceptLanguage;\n }\n\n /**\n * Gets the details of a purchased phone number. Includes phone number, cost, country code, etc.\n *\n * @param phoneNumber - The E.164 formatted phone number being fetched. The leading plus can be either + or encoded as %2B.\n * @param options - Additional request options.\n */\n public getPurchasedPhoneNumber(\n phoneNumber: string,\n options: GetPurchasedPhoneNumberOptions = {},\n ): Promise<PurchasedPhoneNumber> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-getPurchasedPhoneNumber\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.getByNumber(phoneNumber, {\n ...updatedOptions,\n });\n },\n );\n }\n\n /**\n * Iterates the purchased phone numbers.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const purchased of client.listPhoneNumbers()) {\n * console.log(\"phone number: \", purchased.phoneNumber);\n * }\n * ```\n * List all purchased phone numbers.\n * @param options - The optional parameters.\n */\n public listPurchasedPhoneNumbers(\n options: ListPurchasedPhoneNumbersOptions = {},\n ): PagedAsyncIterableIterator<PurchasedPhoneNumber> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listPurchasedPhoneNumbers\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listPhoneNumbers({\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Starts the release of a purchased phone number.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts\n * const client = new PhoneNumbersClient(CONNECTION_STRING);\n * const releasePoller = await client.beginReleasePhoneNumber(\"+14125550100\");\n *\n * // Serializing the poller\n * const serialized = releasePoller.toString();\n *\n * // Waiting until it's done\n * const results = await releasePoller.pollUntilDone();\n * console.log(results);\n * ```\n * @param phoneNumber - The E.164 formatted phone number being released. The leading plus can be either + or encoded as %2B.\n * @param options - Additional request options.\n */\n public beginReleasePhoneNumber(\n phoneNumber: string,\n options: BeginReleasePhoneNumberOptions = {},\n ): Promise<PollerLike<PollOperationState<ReleasePhoneNumberResult>, ReleasePhoneNumberResult>> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginReleasePhoneNumber\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginReleasePhoneNumber(phoneNumber, updatedOptions);\n },\n );\n }\n\n /**\n * Starts a search for phone numbers given some constraints such as name or area code.\n * The phone numbers that are found are reserved until you cancel, purchase or the reservation expires.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts\n * const client = new PhoneNumberAdministrationClient(CONNECTION_STRING);\n * const searchPoller = await client.beginSearchAvailablePhoneNumbers(SEARCH_REQUEST);\n *\n * // Serializing the poller\n * const serialized = searchPoller.toString();\n *\n * // Waiting until it's done\n * const results = await searchPoller.pollUntilDone();\n * console.log(results);\n * ```\n *\n * @param search - Request properties to constraint the search scope.\n * @param options - Additional request options.\n */\n public beginSearchAvailablePhoneNumbers(\n search: SearchAvailablePhoneNumbersRequest,\n options: BeginSearchAvailablePhoneNumbersOptions = {},\n ): Promise<PollerLike<PollOperationState<PhoneNumberSearchResult>, PhoneNumberSearchResult>> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginSearchAvailablePhoneNumbers\",\n options,\n (updatedOptions) => {\n const { countryCode, phoneNumberType, assignmentType, capabilities, ...rest } = search;\n return this.client.phoneNumbers.beginSearchAvailablePhoneNumbers(\n countryCode,\n phoneNumberType,\n assignmentType,\n capabilities,\n {\n ...updatedOptions,\n ...rest,\n },\n );\n },\n );\n }\n\n /**\n * Starts the purchase of the phone number(s) in the search associated with a given id.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts\n * const client = new PhoneNumbersClient(CONNECTION_STRING);\n * const purchasePoller = await client.beginPurchasePhoneNumbers(SEARCH_ID);\n *\n * // Serializing the poller\n * const serialized = purchasePoller.toString();\n *\n * // Waiting until it's done\n * const results = await purchasePoller.pollUntilDone();\n * console.log(results);\n * ```\n *\n * @param searchId - The id of the search to purchase. Returned from `beginSearchAvailablePhoneNumbers`\n * @param options - Additional request options.\n */\n public beginPurchasePhoneNumbers(\n searchId: string,\n options: BeginPurchasePhoneNumbersOptions = {},\n ): Promise<\n PollerLike<PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>\n > {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginPurchasePhoneNumbers\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginPurchasePhoneNumbers({ ...updatedOptions, searchId });\n },\n );\n }\n\n /**\n * Starts the update of a purchased phone number's capabilities.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts\n * const client = new PhoneNumbersClient(CONNECTION_STRING);\n * const updatePoller = await client.beginUpdatePhoneNumberCapabilities(\"+14125550100\", UPDATE_REQUEST);\n *\n * // Serializing the poller\n * const serialized = updatePoller.toString();\n *\n * // Waiting until it's done\n * const results = await updatePoller.pollUntilDone();\n * console.log(results);\n * ```\n *\n * @param phoneNumber - The E.164 formatted phone number being updated. The leading plus can be either + or encoded as %2B.\n * @param request - The updated properties which will be applied to the phone number.\n * @param options - Additional request options.\n */\n public beginUpdatePhoneNumberCapabilities(\n phoneNumber: string,\n request: PhoneNumberCapabilitiesRequest,\n options: BeginUpdatePhoneNumberCapabilitiesOptions = {},\n ): Promise<PollerLike<PollOperationState<PurchasedPhoneNumber>, PurchasedPhoneNumber>> {\n if (!phoneNumber) {\n throw Error(\"phone number can't be empty\");\n }\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginUpdatePhoneNumberCapabilities\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginUpdateCapabilities(phoneNumber, {\n ...updatedOptions,\n ...request,\n });\n },\n );\n }\n\n /**\n * Iterates the available countries.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const country of client.listAvailableCountries()) {\n * console.log(\"country: \", country.localizedName);\n * }\n * ```\n * List all available countries.\n * @param options - The optional parameters.\n */\n public listAvailableCountries(\n options: ListAvailableCountriesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberCountry> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableCountries\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAvailableCountries({\n ...updatedOptions,\n acceptLanguage: this.acceptLanguage,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available Toll-Free area codes.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const areaCodeItem of client.listTollFreeAreaCodes()) {\n * console.log(\"area code: \", areaCodeItem.areaCode);\n * }\n * ```\n * List all available Toll-Free area codes.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableTollFreeAreaCodes(\n countryCode: string,\n options: ListTollFreeAreaCodesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberAreaCode> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableTollFreeAreaCodes\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAreaCodes(countryCode, \"tollFree\", {\n ...updatedOptions,\n assignmentType: \"application\",\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available Geographic area codes.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const areaCodeItem of client.listGeographicAreaCodes()) {\n * console.log(\"area code: \", areaCodeItem.areaCode);\n * }\n * ```\n * List all available Geographic area codes.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableGeographicAreaCodes(\n countryCode: string,\n options: ListGeographicAreaCodesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberAreaCode> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableGeographicFreeAreaCodes\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAreaCodes(countryCode, \"geographic\", {\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available localities.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const locality of client.listAvailableLocalities()) {\n * console.log(\"locality: \", locality.localizedName);\n * }\n * ```\n * List all available localities.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableLocalities(\n countryCode: string,\n options: ListLocalitiesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberLocality> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableLocalities\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAvailableLocalities(countryCode, {\n ...updatedOptions,\n acceptLanguage: this.acceptLanguage,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available offerings.\n *\n * Example usage:\n * ```ts\n * let client = new PhoneNumbersClient(credentials);\n * for await (const offering of client.listAvailableOfferings()) {\n * console.log(\"phone number type: \", offering.phoneNumberType);\n * console.log(\"cost: \", offering.cost.amount);\n * }\n * ```\n * List all available offerings.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableOfferings(\n countryCode: string,\n options: ListOfferingsOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberOffering> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listOfferings\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listOfferings(countryCode, {\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Search for operator information about specified phone numbers.\n *\n * @param phoneNumbers - The phone numbers to search.\n * @param options - Additional request options.\n */\n public searchOperatorInformation(\n phoneNumbers: string[],\n options: SearchOperatorInformationOptions = { includeAdditionalOperatorDetails: false },\n ): Promise<OperatorInformationResult> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-searchOperatorInformation\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.operatorInformationSearch(phoneNumbers, {\n ...updatedOptions,\n options: { includeAdditionalOperatorDetails: options.includeAdditionalOperatorDetails },\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"phoneNumbersClient.js","sourceRoot":"","sources":["../../src/phoneNumbersClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;AAE5C,uDAAuD;AACvD,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AA8B7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAY3D,MAAM,2BAA2B,GAAG,CAAC,OAAY,EAAwC,EAAE,CACzF,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAoC7B,YACE,qBAA6B,EAC7B,mBAAiF,EACjF,eAA0C,EAAE;QAE5C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,2BAA2B,CAAC,mBAAmB,CAAC;YAC9D,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAAY,CAAC;QAEjB,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAA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ent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/// <reference lib=\"esnext.asynciterable\" />\n\n/* eslint-disable @azure/azure-sdk/ts-naming-options */\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport type { PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { PhoneNumbersClient as PhoneNumbersGeneratedClient } from \"./generated/src/index.js\";\nimport type {\n OperatorInformationResult,\n PhoneNumberAreaCode,\n PhoneNumberCapabilitiesRequest,\n PhoneNumberCountry,\n PhoneNumberLocality,\n PhoneNumberOffering,\n PhoneNumberSearchResult,\n PurchasedPhoneNumber,\n} from \"./generated/src/models/index.js\";\nimport type {\n GetPurchasedPhoneNumberOptions,\n ListAvailableCountriesOptions,\n ListGeographicAreaCodesOptions,\n ListLocalitiesOptions,\n ListOfferingsOptions,\n ListPurchasedPhoneNumbersOptions,\n ListTollFreeAreaCodesOptions,\n PurchasePhoneNumbersResult,\n ReleasePhoneNumberResult,\n SearchAvailablePhoneNumbersRequest,\n SearchOperatorInformationOptions,\n} from \"./models.js\";\nimport type {\n BeginPurchasePhoneNumbersOptions,\n BeginReleasePhoneNumberOptions,\n BeginSearchAvailablePhoneNumbersOptions,\n BeginUpdatePhoneNumberCapabilitiesOptions,\n} from \"./lroModels.js\";\nimport { createPhoneNumbersPagingPolicy } from \"./utils/customPipelinePolicies.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { logger } from \"./utils/index.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\n/**\n * Client options used to configure the PhoneNumbersClient API requests.\n */\nexport interface PhoneNumbersClientOptions extends CommonClientOptions {\n /**\n * The accept language parameter to be used in the request header's \"accept-language\" property.\n */\n acceptLanguage?: string;\n}\n\nconst isPhoneNumbersClientOptions = (options: any): options is PhoneNumbersClientOptions =>\n options && !isKeyCredential(options) && !isTokenCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services Phone Number Administration.\n */\nexport class PhoneNumbersClient {\n /**\n * A reference to the auto-generated PhoneNumber HTTP client.\n */\n private readonly client: PhoneNumbersGeneratedClient;\n\n /**\n * The accept language parameter to be used in the request header's \"accept-language\" property.\n */\n private acceptLanguage: string | undefined;\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using a connection string.\n *\n * @param connectionString - Connection string to connect to an Azure Communication Service resource. (eg: endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret)\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: PhoneNumbersClientOptions);\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using an Azure KeyCredential.\n *\n * @param url - The endpoint of the service (eg: https://contoso.eastus.communications.azure.net)\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(url: string, credential: KeyCredential, options?: PhoneNumbersClientOptions);\n\n /**\n * Initializes a new instance of the PhoneNumberAdministrationClient class using a TokenCredential.\n * @param url - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(url: string, credential: TokenCredential, options?: PhoneNumbersClientOptions);\n\n public constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | PhoneNumbersClientOptions,\n maybeOptions: PhoneNumbersClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isPhoneNumbersClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new PhoneNumbersGeneratedClient(url, {\n endpoint: url,\n ...internalPipelineOptions,\n });\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n\n // This policy is temporary workarounds to address compatibility issues with Azure Core V2.\n const phoneNumbersPagingPolicy = createPhoneNumbersPagingPolicy(url);\n this.client.pipeline.addPolicy(phoneNumbersPagingPolicy);\n this.acceptLanguage = maybeOptions.acceptLanguage;\n }\n\n /**\n * Gets the details of a purchased phone number. Includes phone number, cost, country code, etc.\n *\n * @param phoneNumber - The E.164 formatted phone number being fetched. The leading plus can be either + or encoded as %2B.\n * @param options - Additional request options.\n */\n public getPurchasedPhoneNumber(\n phoneNumber: string,\n options: GetPurchasedPhoneNumberOptions = {},\n ): Promise<PurchasedPhoneNumber> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-getPurchasedPhoneNumber\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.getByNumber(phoneNumber, {\n ...updatedOptions,\n });\n },\n );\n }\n\n /**\n * Iterates the purchased phone numbers.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListPurchasedPhoneNumbers\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * const phoneNumbers = client.listPurchasedPhoneNumbers();\n *\n * for await (const phoneNumber of phoneNumbers) {\n * console.log(`The id is the same as the phone number: ${phoneNumber.id}`);\n * console.log(`Phone number type is ${phoneNumber.phoneNumberType}`);\n * }\n * ```\n * List all purchased phone numbers.\n * @param options - The optional parameters.\n */\n public listPurchasedPhoneNumbers(\n options: ListPurchasedPhoneNumbersOptions = {},\n ): PagedAsyncIterableIterator<PurchasedPhoneNumber> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listPurchasedPhoneNumbers\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listPhoneNumbers({\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Starts the release of a purchased phone number.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientReleasePhoneNumber\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * const phoneNumberToRelease = \"<phone-number-to-release>\";\n *\n * const releasePoller = await client.beginReleasePhoneNumber(phoneNumberToRelease);\n *\n * // Release is underway.\n * await releasePoller.pollUntilDone();\n * console.log(\"Successfully release phone number.\");\n * ```\n * @param phoneNumber - The E.164 formatted phone number being released. The leading plus can be either + or encoded as %2B.\n * @param options - Additional request options.\n */\n public beginReleasePhoneNumber(\n phoneNumber: string,\n options: BeginReleasePhoneNumberOptions = {},\n ): Promise<PollerLike<PollOperationState<ReleasePhoneNumberResult>, ReleasePhoneNumberResult>> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginReleasePhoneNumber\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginReleasePhoneNumber(phoneNumber, updatedOptions);\n },\n );\n }\n\n /**\n * Starts a search for phone numbers given some constraints such as name or area code.\n * The phone numbers that are found are reserved until you cancel, purchase or the reservation expires.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientSearchAvailablePhoneNumbers\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import {\n * PhoneNumbersClient,\n * SearchAvailablePhoneNumbersRequest,\n * } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * const searchRequest: SearchAvailablePhoneNumbersRequest = {\n * countryCode: \"US\",\n * phoneNumberType: \"tollFree\",\n * assignmentType: \"application\",\n * capabilities: {\n * sms: \"outbound\",\n * calling: \"none\",\n * },\n * quantity: 1,\n * };\n *\n * const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);\n *\n * // The search is underway. Wait to receive searchId.\n * const searchResults = await searchPoller.pollUntilDone();\n * console.log(`Found phone number: ${searchResults.phoneNumbers[0]}`);\n * console.log(`searchId: ${searchResults.searchId}`);\n * ```\n *\n * @param search - Request properties to constraint the search scope.\n * @param options - Additional request options.\n */\n public beginSearchAvailablePhoneNumbers(\n search: SearchAvailablePhoneNumbersRequest,\n options: BeginSearchAvailablePhoneNumbersOptions = {},\n ): Promise<PollerLike<PollOperationState<PhoneNumberSearchResult>, PhoneNumberSearchResult>> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginSearchAvailablePhoneNumbers\",\n options,\n (updatedOptions) => {\n const { countryCode, phoneNumberType, assignmentType, capabilities, ...rest } = search;\n return this.client.phoneNumbers.beginSearchAvailablePhoneNumbers(\n countryCode,\n phoneNumberType,\n assignmentType,\n capabilities,\n {\n ...updatedOptions,\n ...rest,\n },\n );\n },\n );\n }\n\n /**\n * Starts the purchase of the phone number(s) in the search associated with a given id.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientPurchasePhoneNumbers\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import {\n * PhoneNumbersClient,\n * SearchAvailablePhoneNumbersRequest,\n * } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * const searchRequest: SearchAvailablePhoneNumbersRequest = {\n * countryCode: \"US\",\n * phoneNumberType: \"tollFree\",\n * assignmentType: \"application\",\n * capabilities: {\n * sms: \"outbound\",\n * calling: \"none\",\n * },\n * quantity: 1,\n * };\n *\n * const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);\n *\n * // The search is underway. Wait to receive searchId.\n * const { searchId, phoneNumbers } = await searchPoller.pollUntilDone();\n *\n * const purchasePoller = await client.beginPurchasePhoneNumbers(searchId);\n *\n * // Purchase is underway.\n * await purchasePoller.pollUntilDone();\n * console.log(`Successfully purchased ${phoneNumbers[0]}`);\n * ```\n *\n * @param searchId - The id of the search to purchase. Returned from `beginSearchAvailablePhoneNumbers`\n * @param options - Additional request options.\n */\n public beginPurchasePhoneNumbers(\n searchId: string,\n options: BeginPurchasePhoneNumbersOptions = {},\n ): Promise<\n PollerLike<PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>\n > {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginPurchasePhoneNumbers\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginPurchasePhoneNumbers({ ...updatedOptions, searchId });\n },\n );\n }\n\n /**\n * Starts the update of a purchased phone number's capabilities.\n *\n * This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientUpdatePhoneNumberCapabilities\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import {\n * PhoneNumbersClient,\n * PhoneNumberCapabilitiesRequest,\n * } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * const phoneNumberToUpdate = \"<phone-number-to-update>\";\n *\n * // This will update phone number to send and receive sms, but only send calls.\n * const updateRequest: PhoneNumberCapabilitiesRequest = {\n * sms: \"inbound+outbound\",\n * calling: \"outbound\",\n * };\n *\n * const updatePoller = await client.beginUpdatePhoneNumberCapabilities(\n * phoneNumberToUpdate,\n * updateRequest,\n * );\n *\n * // Update is underway.\n * const { capabilities } = await updatePoller.pollUntilDone();\n * console.log(`These are the update capabilities: ${capabilities}`);\n * ```\n *\n * @param phoneNumber - The E.164 formatted phone number being updated. The leading plus can be either + or encoded as %2B.\n * @param request - The updated properties which will be applied to the phone number.\n * @param options - Additional request options.\n */\n public beginUpdatePhoneNumberCapabilities(\n phoneNumber: string,\n request: PhoneNumberCapabilitiesRequest,\n options: BeginUpdatePhoneNumberCapabilitiesOptions = {},\n ): Promise<PollerLike<PollOperationState<PurchasedPhoneNumber>, PurchasedPhoneNumber>> {\n if (!phoneNumber) {\n throw Error(\"phone number can't be empty\");\n }\n return tracingClient.withSpan(\n \"PhoneNumbersClient-beginUpdatePhoneNumberCapabilities\",\n options,\n (updatedOptions) => {\n return this.client.phoneNumbers.beginUpdateCapabilities(phoneNumber, {\n ...updatedOptions,\n ...request,\n });\n },\n );\n }\n\n /**\n * Iterates the available countries.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListAvailableCountries\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * for await (const country of client.listAvailableCountries()) {\n * console.log(\"country: \", country.localizedName);\n * }\n * ```\n * List all available countries.\n * @param options - The optional parameters.\n */\n public listAvailableCountries(\n options: ListAvailableCountriesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberCountry> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableCountries\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAvailableCountries({\n ...updatedOptions,\n acceptLanguage: this.acceptLanguage,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available Toll-Free area codes.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListTollFreeAreaCodes\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * for await (const areaCodeItem of client.listAvailableTollFreeAreaCodes(\"US\")) {\n * console.log(\"area code: \", areaCodeItem.areaCode);\n * }\n * ```\n * List all available Toll-Free area codes.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableTollFreeAreaCodes(\n countryCode: string,\n options: ListTollFreeAreaCodesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberAreaCode> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableTollFreeAreaCodes\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAreaCodes(countryCode, \"tollFree\", {\n ...updatedOptions,\n assignmentType: \"application\",\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available Geographic area codes.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListGeographicAreaCodes\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * for await (const areaCodeItem of client.listAvailableGeographicAreaCodes(\"US\")) {\n * console.log(\"area code: \", areaCodeItem.areaCode);\n * }\n * ```\n * List all available Geographic area codes.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableGeographicAreaCodes(\n countryCode: string,\n options: ListGeographicAreaCodesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberAreaCode> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableGeographicFreeAreaCodes\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAreaCodes(countryCode, \"geographic\", {\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available localities.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListAvailableLocalities\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * for await (const locality of client.listAvailableLocalities(\"US\")) {\n * console.log(\"locality: \", locality.localizedName);\n * }\n * ```\n * List all available localities.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableLocalities(\n countryCode: string,\n options: ListLocalitiesOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberLocality> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listAvailableLocalities\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listAvailableLocalities(countryCode, {\n ...updatedOptions,\n acceptLanguage: this.acceptLanguage,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Iterates the available offerings.\n *\n * Example usage:\n * ```ts snippet:PhoneNumbersClientListAvailableOfferings\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { PhoneNumbersClient } from \"@azure/communication-phone-numbers\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = new PhoneNumbersClient(\"<endpoint-from-resource>\", credential);\n *\n * for await (const offering of client.listAvailableOfferings(\"US\")) {\n * console.log(\"phone number type: \", offering.phoneNumberType);\n * console.log(\"cost: \", offering.cost.amount);\n * }\n * ```\n * List all available offerings.\n * @param countryCode - The ISO 3166-2 country code.\n * @param options - The optional parameters.\n */\n public listAvailableOfferings(\n countryCode: string,\n options: ListOfferingsOptions = {},\n ): PagedAsyncIterableIterator<PhoneNumberOffering> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-listOfferings\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.listOfferings(countryCode, {\n ...updatedOptions,\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n\n /**\n * Search for operator information about specified phone numbers.\n *\n * @param phoneNumbers - The phone numbers to search.\n * @param options - Additional request options.\n */\n public searchOperatorInformation(\n phoneNumbers: string[],\n options: SearchOperatorInformationOptions = { includeAdditionalOperatorDetails: false },\n ): Promise<OperatorInformationResult> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"PhoneNumbersClient-searchOperatorInformation\",\n options,\n );\n\n try {\n return this.client.phoneNumbers.operatorInformationSearch(phoneNumbers, {\n ...updatedOptions,\n options: { includeAdditionalOperatorDetails: options.includeAdditionalOperatorDetails },\n });\n } catch (e: any) {\n span.setStatus({\n status: \"error\",\n error: e,\n });\n\n throw e;\n } finally {\n span.end();\n }\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-phone-numbers",
|
3
|
-
"version": "1.3.0-alpha.
|
3
|
+
"version": "1.3.0-alpha.20250127.1",
|
4
4
|
"description": "SDK for Azure Communication service which facilitates phone number management.",
|
5
5
|
"sdk-type": "client",
|
6
6
|
"main": "./dist/commonjs/index.js",
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
32
32
|
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
33
33
|
"unit-test:node": "dev-tool run test:vitest",
|
34
|
-
"update-snippets": "
|
34
|
+
"update-snippets": "dev-tool run update-snippets"
|
35
35
|
},
|
36
36
|
"files": [
|
37
37
|
"dist/",
|
@@ -58,16 +58,16 @@
|
|
58
58
|
"dependencies": {
|
59
59
|
"@azure/abort-controller": "^2.0.0",
|
60
60
|
"@azure/communication-common": "^2.3.1",
|
61
|
-
"@azure/core-auth": "^1.
|
62
|
-
"@azure/core-client": "^1.
|
63
|
-
"@azure/core-lro": "^2.2
|
64
|
-
"@azure/core-paging": "^1.
|
65
|
-
"@azure/core-rest-pipeline": "^1.
|
66
|
-
"@azure/core-tracing": "^1.
|
67
|
-
"@azure/core-util": "^1.
|
68
|
-
"@azure/logger": "^1.
|
69
|
-
"events": "^3.
|
70
|
-
"tslib": "^2.
|
61
|
+
"@azure/core-auth": "^1.9.0",
|
62
|
+
"@azure/core-client": "^1.9.2",
|
63
|
+
"@azure/core-lro": "^2.7.2",
|
64
|
+
"@azure/core-paging": "^1.6.2",
|
65
|
+
"@azure/core-rest-pipeline": "^1.18.2",
|
66
|
+
"@azure/core-tracing": "^1.2.0",
|
67
|
+
"@azure/core-util": "^1.11.0",
|
68
|
+
"@azure/logger": "^1.1.4",
|
69
|
+
"events": "^3.3.0",
|
70
|
+
"tslib": "^2.8.1"
|
71
71
|
},
|
72
72
|
"devDependencies": {
|
73
73
|
"@azure-tools/test-credential": "^2.0.0",
|
@@ -75,15 +75,15 @@
|
|
75
75
|
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
76
76
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
77
77
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
78
|
-
"@azure/identity": "^4.0
|
78
|
+
"@azure/identity": "^4.5.0",
|
79
79
|
"@types/node": "^18.0.0",
|
80
|
-
"@vitest/browser": "^
|
81
|
-
"@vitest/coverage-istanbul": "^
|
80
|
+
"@vitest/browser": "^3.0.3",
|
81
|
+
"@vitest/coverage-istanbul": "^3.0.3",
|
82
82
|
"dotenv": "^16.0.0",
|
83
83
|
"eslint": "^9.9.0",
|
84
84
|
"playwright": "^1.48.2",
|
85
85
|
"typescript": "~5.7.2",
|
86
|
-
"vitest": "^
|
86
|
+
"vitest": "^3.0.3"
|
87
87
|
},
|
88
88
|
"//metadata": {
|
89
89
|
"constantPaths": [
|