@azure/communication-phone-numbers 1.2.1-alpha.20230720.1 → 1.3.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +159 -2
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +110 -0
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +6 -2
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/phoneNumbers.js +30 -0
- package/dist-esm/src/generated/src/operations/phoneNumbers.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/phoneNumbers.js.map +1 -1
- package/dist-esm/src/generated/src/phoneNumbersClient.js +1 -1
- package/dist-esm/src/generated/src/phoneNumbersClient.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/phoneNumbersClient.js +13 -0
- package/dist-esm/src/phoneNumbersClient.js.map +1 -1
- package/package.json +4 -4
- package/types/communication-phone-numbers.d.ts +55 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"phoneNumbersClient.js","sourceRoot":"","sources":["../../src/phoneNumbersClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;AAE5C,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrF,OAAO,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AA4BpF,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAYxD,MAAM,2BAA2B,GAAG,CAAC,OAAY,EAAwC,EAAE,CACzF,OAAO,IAAI,C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C,YAAY,CAAC,uBAAuB,CAAC,WAAW,kCAC9D,cAAc,KACjB,cAAc,EAAE,IAAI,CAAC,cAAc,IACnC,CAAC;SACJ;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;YAEH,MAAM,CAAC,CAAC;SACT;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,sBAAsB,CAC3B,WAAmB,EACnB,UAAgC,EAAE;QAElC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,kCAAkC,EAClC,OAAO,CACR,CAAC;QAEF,IAAI;YACF,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,WAAW,oBACpD,cAAc,EACjB,CAAC;SACJ;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,CAAC;aACT,CAAC,CAAC;YAEH,MAAM,CAAC,CAAC;SACT;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { PhoneNumbersClient as PhoneNumbersGeneratedClient } from \"./generated/src\";\nimport {\n PhoneNumberAreaCode,\n PhoneNumberCapabilitiesRequest,\n PhoneNumberCountry,\n PhoneNumberLocality,\n PhoneNumberOffering,\n PhoneNumberSearchResult,\n PurchasedPhoneNumber,\n} from \"./generated/src/models/\";\nimport {\n GetPurchasedPhoneNumberOptions,\n ListAvailableCountriesOptions,\n ListGeographicAreaCodesOptions,\n ListLocalitiesOptions,\n ListOfferingsOptions,\n ListPurchasedPhoneNumbersOptions,\n ListTollFreeAreaCodesOptions,\n PurchasePhoneNumbersResult,\n ReleasePhoneNumberResult,\n SearchAvailablePhoneNumbersRequest,\n} from \"./models\";\nimport {\n BeginPurchasePhoneNumbersOptions,\n BeginReleasePhoneNumberOptions,\n BeginSearchAvailablePhoneNumbersOptions,\n BeginUpdatePhoneNumberCapabilitiesOptions,\n} from \"./lroModels\";\nimport { createPhoneNumbersPagingPolicy } from \"./utils/customPipelinePolicies\";\nimport { CommonClientOptions } from \"@azure/core-client\";\nimport { logger } from \"./utils\";\nimport { tracingClient } from \"./generated/src/tracing\";\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"]}
|
1
|
+
{"version":3,"file":"phoneNumbersClient.js","sourceRoot":"","sources":["../../src/phoneNumbersClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;AAE5C,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,G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EAAE;QAE9C,OAAO,aAAa,CAAC,QAAQ,CAC3B,8CAA8C,EAC9C,OAAO,EACP,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,MAAM,GAAwD,cAAc,CAAC;YACnF,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;YACnC,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QACpE,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { PhoneNumbersClient as PhoneNumbersGeneratedClient } from \"./generated/src\";\nimport {\n OperatorInformationResult,\n PhoneNumberAreaCode,\n PhoneNumberCapabilitiesRequest,\n PhoneNumberCountry,\n PhoneNumberLocality,\n PhoneNumberOffering,\n PhoneNumberSearchResult,\n PhoneNumbersOperatorInformationSearchOptionalParams,\n PurchasedPhoneNumber,\n} from \"./generated/src/models/\";\nimport {\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\";\nimport {\n BeginPurchasePhoneNumbersOptions,\n BeginReleasePhoneNumberOptions,\n BeginSearchAvailablePhoneNumbersOptions,\n BeginUpdatePhoneNumberCapabilitiesOptions,\n} from \"./lroModels\";\nimport { createPhoneNumbersPagingPolicy } from \"./utils/customPipelinePolicies\";\nimport { CommonClientOptions } from \"@azure/core-client\";\nimport { logger } from \"./utils\";\nimport { tracingClient } from \"./generated/src/tracing\";\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 = {}\n ): Promise<OperatorInformationResult> {\n return tracingClient.withSpan(\n \"PhoneNumbersClient-searchOperatorInformation\",\n options,\n (updatedOptions) => {\n const params: PhoneNumbersOperatorInformationSearchOptionalParams = updatedOptions;\n params.phoneNumbers = phoneNumbers;\n return this.client.phoneNumbers.operatorInformationSearch(params);\n }\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
|
+
"version": "1.3.0-beta.1",
|
4
4
|
"description": "SDK for Azure Communication service which facilitates phone number management.",
|
5
5
|
"sdk-type": "client",
|
6
6
|
"main": "dist/index.js",
|
@@ -73,9 +73,9 @@
|
|
73
73
|
},
|
74
74
|
"devDependencies": {
|
75
75
|
"@azure/core-util": "^1.0.0",
|
76
|
-
"@azure/dev-tool": "
|
77
|
-
"@azure/eslint-plugin-azure-sdk": "
|
78
|
-
"@azure/test-utils": "
|
76
|
+
"@azure/dev-tool": "^1.0.0",
|
77
|
+
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
78
|
+
"@azure/test-utils": "^1.0.0",
|
79
79
|
"@azure-tools/test-credential": "^1.0.0",
|
80
80
|
"@azure-tools/test-recorder": "^3.0.0",
|
81
81
|
"@azure/identity": "^2.0.1",
|
@@ -89,6 +89,40 @@ export declare interface ListSipTrunksOptions extends OperationOptions {
|
|
89
89
|
export declare interface ListTollFreeAreaCodesOptions extends Omit<PhoneNumbersListAreaCodesOptionalParams, "assignmentType" | "locality" | "administrativeDivision"> {
|
90
90
|
}
|
91
91
|
|
92
|
+
/** Represents metadata describing the operator of a phone number */
|
93
|
+
export declare interface OperatorDetails {
|
94
|
+
/** Name of the phone operator */
|
95
|
+
name?: string;
|
96
|
+
/** Mobile Network Code */
|
97
|
+
mobileNetworkCode?: string;
|
98
|
+
/** Mobile Country Code */
|
99
|
+
mobileCountryCode?: string;
|
100
|
+
}
|
101
|
+
|
102
|
+
/** Represents metadata about a phone number that is controlled/provided by that phone number's operator. */
|
103
|
+
export declare interface OperatorInformation {
|
104
|
+
/** E.164 formatted string representation of the phone number */
|
105
|
+
phoneNumber?: string;
|
106
|
+
/** Type of service associated with the phone number */
|
107
|
+
numberType?: OperatorNumberType;
|
108
|
+
/** ISO country code associated with the phone number. */
|
109
|
+
isoCountryCode?: string;
|
110
|
+
/** Represents metadata describing the operator of a phone number */
|
111
|
+
operatorDetails?: OperatorDetails;
|
112
|
+
}
|
113
|
+
|
114
|
+
/** Represents a search result containing operator information associated with the requested phone numbers */
|
115
|
+
export declare interface OperatorInformationResult {
|
116
|
+
/**
|
117
|
+
* Results of a search.
|
118
|
+
* This array will have one entry per requested phone number which will contain the relevant operator information.
|
119
|
+
*/
|
120
|
+
values?: OperatorInformation[];
|
121
|
+
}
|
122
|
+
|
123
|
+
/** Defines values for OperatorNumberType. */
|
124
|
+
export declare type OperatorNumberType = "unknown" | "other" | "geographic" | "mobile";
|
125
|
+
|
92
126
|
/** Represents an administrative division. e.g. state or province. */
|
93
127
|
export declare interface PhoneNumberAdministrativeDivision {
|
94
128
|
/** Represents the localized name of the administrative division of the locality. e.g. state or province localized name. */
|
@@ -382,6 +416,13 @@ export declare class PhoneNumbersClient {
|
|
382
416
|
* @param options - The optional parameters.
|
383
417
|
*/
|
384
418
|
listAvailableOfferings(countryCode: string, options?: ListOfferingsOptions): PagedAsyncIterableIterator<PhoneNumberOffering>;
|
419
|
+
/**
|
420
|
+
* Search for operator information about specified phone numbers.
|
421
|
+
*
|
422
|
+
* @param phoneNumbers - The phone numbers to search.
|
423
|
+
* @param options - Additional request options.
|
424
|
+
*/
|
425
|
+
searchOperatorInformation(phoneNumbers: string[], options?: SearchOperatorInformationOptions): Promise<OperatorInformationResult>;
|
385
426
|
}
|
386
427
|
|
387
428
|
/**
|
@@ -424,15 +465,22 @@ export declare interface PhoneNumberSearchResult {
|
|
424
465
|
cost: PhoneNumberCost;
|
425
466
|
/** The date that this search result expires and phone numbers are no longer on hold. A search result expires in less than 15min, e.g. 2020-11-19T16:31:49.048Z. */
|
426
467
|
searchExpiresBy: Date;
|
468
|
+
/** The error code of the search. */
|
469
|
+
errorCode?: number;
|
470
|
+
/** Mapping Error Messages to Codes */
|
471
|
+
error?: PhoneNumberSearchResultError;
|
427
472
|
}
|
428
473
|
|
474
|
+
/** Defines values for PhoneNumberSearchResultError. */
|
475
|
+
export declare type PhoneNumberSearchResultError = "NoError" | "UnknownErrorCode" | "OutOfStock" | "AuthorizationDenied" | "MissingAddress" | "InvalidAddress" | "InvalidOfferModel" | "NotEnoughLicenses" | "NoWallet" | "NotEnoughCredit" | "NumbersPartiallyAcquired" | "AllNumbersNotAcquired" | "ReservationExpired" | "PurchaseFailed" | "BillingUnavailable" | "ProvisioningFailed" | "UnknownSearchError";
|
476
|
+
|
429
477
|
/** Optional parameters. */
|
430
478
|
export declare interface PhoneNumbersListAreaCodesOptionalParams extends coreClient.OperationOptions {
|
431
479
|
/** An optional parameter for how many entries to skip, for pagination purposes. The default value is 0. */
|
432
480
|
skip?: number;
|
433
481
|
/** An optional parameter for how many entries to return, for pagination purposes. The default value is 100. */
|
434
482
|
maxPageSize?: number;
|
435
|
-
/** Filter by assignmentType, e.g.
|
483
|
+
/** Filter by assignmentType, e.g. Person, Application. */
|
436
484
|
assignmentType?: PhoneNumberAssignmentType;
|
437
485
|
/** The name of locality or town in which to search for the area code. This is required if the number type is Geographic. */
|
438
486
|
locality?: string;
|
@@ -488,6 +536,12 @@ export declare interface SearchAvailablePhoneNumbersRequest extends PhoneNumberS
|
|
488
536
|
countryCode: string;
|
489
537
|
}
|
490
538
|
|
539
|
+
/**
|
540
|
+
* Additional options for the search operator information request.
|
541
|
+
*/
|
542
|
+
export declare interface SearchOperatorInformationOptions extends OperationOptions {
|
543
|
+
}
|
544
|
+
|
491
545
|
/**
|
492
546
|
* Client class for interacting with Azure Communication Services SIP Routing Administration.
|
493
547
|
*/
|