次の方法で共有


PhoneNumbersClient class

Azure Communication Services の電話番号管理と対話するためのクライアント クラス。

コンストラクター

PhoneNumbersClient(string, KeyCredential, PhoneNumbersClientOptions)

Azure KeyCredential を使用して、PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

PhoneNumbersClient(string, PhoneNumbersClientOptions)

接続文字列を使用して、PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

PhoneNumbersClient(string, TokenCredential, PhoneNumbersClientOptions)

TokenCredential を使用して PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

メソッド

beginPurchasePhoneNumbers(string, BeginPurchasePhoneNumbersOptions)

指定した ID に関連付けられた検索で、電話番号の購入を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  SearchAvailablePhoneNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const searchRequest: SearchAvailablePhoneNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
  assignmentType: "application",
  capabilities: {
    sms: "outbound",
    calling: "none",
  },
  quantity: 1,
};

const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);

// The search is underway. Wait to receive searchId.
const { searchId, phoneNumbers } = await searchPoller.pollUntilDone();

const purchasePoller = await client.beginPurchasePhoneNumbers(searchId);

// Purchase is underway.
await purchasePoller.pollUntilDone();
console.log(`Successfully purchased ${phoneNumbers[0]}`);
beginReleasePhoneNumber(string, BeginReleasePhoneNumberOptions)

購入した電話番号のリリースを開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumberToRelease = "<phone-number-to-release>";

const releasePoller = await client.beginReleasePhoneNumber(phoneNumberToRelease);

// Release is underway.
await releasePoller.pollUntilDone();
console.log("Successfully release phone number.");
beginReservationPurchase(string, BeginReservationPurchaseOptions)

指定した ID に関連付けられた検索で、電話番号の購入を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";

const purchasePoller = await client.beginReservationPurchase(reservationId);

// Purchase is underway.
const purchaseResult = await purchasePoller.pollUntilDone();
console.log(`Successfully purchased phone numbers in reservation: ${reservationId}`);

指定されたIDで予約の電話番号の購入を開始します。

beginSearchAvailablePhoneNumbers(SearchAvailablePhoneNumbersRequest, BeginSearchAvailablePhoneNumbersOptions)

名前や地域コードなどの制約がある場合、電話番号の検索を開始します。 見つかった電話番号は、キャンセル、購入、または予約の有効期限が切れるまで予約されます。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  SearchAvailablePhoneNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const searchRequest: SearchAvailablePhoneNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
  assignmentType: "application",
  capabilities: {
    sms: "outbound",
    calling: "none",
  },
  quantity: 1,
};

const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);

// The search is underway. Wait to receive searchId.
const searchResults = await searchPoller.pollUntilDone();
console.log(`Found phone number: ${searchResults.phoneNumbers[0]}`);
console.log(`searchId: ${searchResults.searchId}`);
beginUpdatePhoneNumberCapabilities(string, PhoneNumberCapabilitiesRequest, BeginUpdatePhoneNumberCapabilitiesOptions)

購入した電話番号の機能の更新を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  PhoneNumberCapabilitiesRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumberToUpdate = "<phone-number-to-update>";

// This will update phone number to send and receive sms, but only send calls.
const updateRequest: PhoneNumberCapabilitiesRequest = {
  sms: "inbound+outbound",
  calling: "outbound",
};

const updatePoller = await client.beginUpdatePhoneNumberCapabilities(
  phoneNumberToUpdate,
  updateRequest,
);

// Update is underway.
const { capabilities } = await updatePoller.pollUntilDone();
console.log(`These are the update capabilities: ${capabilities}`);
browseAvailablePhoneNumbers(BrowseAvailableNumbersRequest, BrowseAvailableNumbersOptions)

購入できる電話番号を参照します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  BrowseAvailableNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const browseAvailableNumberRequest: BrowseAvailableNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
};
const browseAvailableNumbers = await client.browseAvailablePhoneNumbers(
  browseAvailableNumberRequest,
  {
    capabilities: {
      calling: "outbound",
    },
    assignmentType: "application",
  },
);
for (const phoneNumber of browseAvailableNumbers.phoneNumbers) {
  console.log("Found phone number: ", phoneNumber.phoneNumber);
}

利用可能な電話番号を閲覧する

createOrUpdateReservation(CreateOrUpdateReservationRequest, CreateOrUpdateReservationOptions)

指定された ID を持つ予約に電話番号を追加および削除します。 応答は、予約の更新された状態になります。 電話番号は、ペイロードに含めることで予約できます。 予約に既に数値が含まれている場合は無視されます。 電話番号を削除するには、要求ペイロードで明示的に null に設定します。 この操作はべき等です。 同じ ID の予約が既に存在する場合は更新され、それ以外の場合は新しい予約が作成されます。 "アクティブ" 状態の予約のみを更新できます。 予約を更新すると、予約の有効期限が最後の変更の 15 分後に延長され、作成時刻から最大 2 時間まで延長されます。 部分的な成功が可能です。この場合、応答には 207 状態コードが含まれます。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  BrowseAvailableNumbersRequest,
  AvailablePhoneNumber,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const browseAvailableNumberRequest: BrowseAvailableNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
};

const browseAvailableNumbers = await client.browseAvailablePhoneNumbers(
  browseAvailableNumberRequest,
  {
    capabilities: {
      calling: "outbound",
    },
    assignmentType: "application",
  },
);
const phoneNumbers = browseAvailableNumbers.phoneNumbers;
const phoneNumbersList = [phoneNumbers[0], phoneNumbers[1]];
const reservationResponse = await client.createOrUpdateReservation(
  {
    reservationId: "reservationId",
  },
  {
    add: phoneNumbersList,
  },
);
const numbersWithError: AvailablePhoneNumber[] = [];
for (const number of Object.values(reservationResponse.phoneNumbers || {})) {
  if (number != null && number.status === "error") {
    numbersWithError.push(number);
  }
}
if (numbersWithError.length > 0) {
  console.log("Errors occurred during reservation");
} else {
  console.log("Reservation operation completed without errors.");
}

予約を作成または更新します。

deleteReservation(string, DeleteReservationOptions)

予約を ID で削除します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";
await client.deleteReservation(reservationId);

console.log(`Reservation with ID ${reservationId} has been deleted.`);

予約を削除します。

getPurchasedPhoneNumber(string, OperationOptions)

購入した電話番号の詳細を取得します。 電話番号、コスト、国コードなどが含まれます。

getReservation(string, GetReservationOptions)

関連付けられているすべての電話番号を含む、指定された ID を持つ予約を取得します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";
const reservationResponse = await client.getReservation(reservationId);

console.log(`Phone numbers in reservation: ${reservationResponse.phoneNumbers}`);

予約を取ります。

listAvailableCountries(ListAvailableCountriesOptions)

使用可能な国を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const country of client.listAvailableCountries()) {
  console.log("country: ", country.localizedName);
}

利用可能なすべての国を一覧表示します。

listAvailableGeographicAreaCodes(string, ListGeographicAreaCodesOptions)

使用可能な地理的エリア コードを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableGeographicAreaCodes("US")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

使用可能なすべての地域コードを一覧表示します。

listAvailableLocalities(string, ListLocalitiesOptions)

使用可能なロケールを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const locality of client.listAvailableLocalities("US")) {
  console.log("locality: ", locality.localizedName);
}

使用可能なすべての地域を一覧表示します。

listAvailableMobileAreaCodes(string, ListMobileAreaCodesOptions)

使用可能なモバイル市外局番を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableMobileAreaCodes("IE")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

利用可能なすべての携帯電話市外局番を一覧表示します。

listAvailableOfferings(string, ListOfferingsOptions)

使用可能なオファリングを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const offering of client.listAvailableOfferings("US")) {
  console.log("phone number type: ", offering.phoneNumberType);
  console.log("cost: ", offering.cost.amount);
}

使用可能なすべてのオファリングを一覧表示します。

listAvailableTollFreeAreaCodes(string, ListTollFreeAreaCodesOptions)

使用可能な Toll-Free 面コードを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableTollFreeAreaCodes("US")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

使用可能なすべての Toll-Free エリア コードを一覧表示します。

listPurchasedPhoneNumbers(ListPurchasedPhoneNumbersOptions)

購入した電話番号を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumbers = client.listPurchasedPhoneNumbers();

for await (const phoneNumber of phoneNumbers) {
  console.log(`The id is the same as the phone number: ${phoneNumber.id}`);
  console.log(`Phone number type is ${phoneNumber.phoneNumberType}`);
}

購入したすべての電話番号を一覧表示します。

listReservations(ListReservationOptions)

すべての電話番号の予約を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const reservation of client.listReservations()) {
  console.log(`Reservation id: ${reservation.id}`);
}

すべての電話番号の予約をリストします。 予約には、関連付けられている電話番号は入力されません。

searchOperatorInformation(string[], SearchOperatorInformationOptions)

指定した電話番号に関するオペレーター情報を検索します。

コンストラクターの詳細

PhoneNumbersClient(string, KeyCredential, PhoneNumbersClientOptions)

Azure KeyCredential を使用して、PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

new PhoneNumbersClient(url: string, credential: KeyCredential, options?: PhoneNumbersClientOptions)

パラメーター

url

string

サービスのエンドポイント (例: https://contoso.eastus.communications.azure.net)

credential
KeyCredential

サービスへの要求を認証するために使用されるオブジェクト。 Azure KeyCredential または @azure/identity を使用して資格情報を作成します。

options
PhoneNumbersClientOptions

随意。 HTTP パイプラインを構成するためのオプション。

PhoneNumbersClient(string, PhoneNumbersClientOptions)

接続文字列を使用して、PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

new PhoneNumbersClient(connectionString: string, options?: PhoneNumbersClientOptions)

パラメーター

connectionString

string

Azure Communication Service リソースに接続するための接続文字列。 (例: endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret)

options
PhoneNumbersClientOptions

随意。 HTTP パイプラインを構成するためのオプション。

PhoneNumbersClient(string, TokenCredential, PhoneNumbersClientOptions)

TokenCredential を使用して PhoneNumberAdministrationClient クラスの新しいインスタンスを初期化します。

new PhoneNumbersClient(url: string, credential: TokenCredential, options?: PhoneNumbersClientOptions)

パラメーター

url

string

サービスのエンドポイント (例: https://contoso.eastus.communications.azure.net)。

credential
TokenCredential

サービスへの要求を認証するために使用される TokenCredential。

options
PhoneNumbersClientOptions

随意。 HTTP パイプラインを構成するためのオプション。

メソッドの詳細

beginPurchasePhoneNumbers(string, BeginPurchasePhoneNumbersOptions)

指定した ID に関連付けられた検索で、電話番号の購入を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  SearchAvailablePhoneNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const searchRequest: SearchAvailablePhoneNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
  assignmentType: "application",
  capabilities: {
    sms: "outbound",
    calling: "none",
  },
  quantity: 1,
};

const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);

// The search is underway. Wait to receive searchId.
const { searchId, phoneNumbers } = await searchPoller.pollUntilDone();

const purchasePoller = await client.beginPurchasePhoneNumbers(searchId);

// Purchase is underway.
await purchasePoller.pollUntilDone();
console.log(`Successfully purchased ${phoneNumbers[0]}`);
function beginPurchasePhoneNumbers(searchId: string, options?: BeginPurchasePhoneNumbersOptions): Promise<PollerLike<PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>>

パラメーター

searchId

string

購入する検索の ID。 beginSearchAvailablePhoneNumbers から返されます

options
BeginPurchasePhoneNumbersOptions

追加の要求オプション。

戻り値

Promise<PollerLike<@azure/core-lro.PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>>

beginReleasePhoneNumber(string, BeginReleasePhoneNumberOptions)

購入した電話番号のリリースを開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumberToRelease = "<phone-number-to-release>";

const releasePoller = await client.beginReleasePhoneNumber(phoneNumberToRelease);

// Release is underway.
await releasePoller.pollUntilDone();
console.log("Successfully release phone number.");
function beginReleasePhoneNumber(phoneNumber: string, options?: BeginReleasePhoneNumberOptions): Promise<PollerLike<PollOperationState<ReleasePhoneNumberResult>, ReleasePhoneNumberResult>>

パラメーター

phoneNumber

string

リリースされる E.164 形式の電話番号。 先頭に +を付けるか、%2Bとしてエンコードできます。

options
BeginReleasePhoneNumberOptions

追加の要求オプション。

戻り値

Promise<PollerLike<@azure/core-lro.PollOperationState<ReleasePhoneNumberResult>, ReleasePhoneNumberResult>>

beginReservationPurchase(string, BeginReservationPurchaseOptions)

指定した ID に関連付けられた検索で、電話番号の購入を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";

const purchasePoller = await client.beginReservationPurchase(reservationId);

// Purchase is underway.
const purchaseResult = await purchasePoller.pollUntilDone();
console.log(`Successfully purchased phone numbers in reservation: ${reservationId}`);

指定されたIDで予約の電話番号の購入を開始します。

function beginReservationPurchase(reservationId: string, options?: BeginReservationPurchaseOptions): Promise<PollerLike<PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>>

パラメーター

reservationId

string

予約の ID。

options
BeginReservationPurchaseOptions

追加の要求オプション。

戻り値

Promise<PollerLike<@azure/core-lro.PollOperationState<PurchasePhoneNumbersResult>, PurchasePhoneNumbersResult>>

beginSearchAvailablePhoneNumbers(SearchAvailablePhoneNumbersRequest, BeginSearchAvailablePhoneNumbersOptions)

名前や地域コードなどの制約がある場合、電話番号の検索を開始します。 見つかった電話番号は、キャンセル、購入、または予約の有効期限が切れるまで予約されます。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  SearchAvailablePhoneNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const searchRequest: SearchAvailablePhoneNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
  assignmentType: "application",
  capabilities: {
    sms: "outbound",
    calling: "none",
  },
  quantity: 1,
};

const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);

// The search is underway. Wait to receive searchId.
const searchResults = await searchPoller.pollUntilDone();
console.log(`Found phone number: ${searchResults.phoneNumbers[0]}`);
console.log(`searchId: ${searchResults.searchId}`);
function beginSearchAvailablePhoneNumbers(search: SearchAvailablePhoneNumbersRequest, options?: BeginSearchAvailablePhoneNumbersOptions): Promise<PollerLike<PollOperationState<PhoneNumberSearchResult>, PhoneNumberSearchResult>>

パラメーター

search
SearchAvailablePhoneNumbersRequest

検索スコープを制約するプロパティを要求します。

options
BeginSearchAvailablePhoneNumbersOptions

追加の要求オプション。

戻り値

Promise<PollerLike<@azure/core-lro.PollOperationState<PhoneNumberSearchResult>, PhoneNumberSearchResult>>

beginUpdatePhoneNumberCapabilities(string, PhoneNumberCapabilitiesRequest, BeginUpdatePhoneNumberCapabilitiesOptions)

購入した電話番号の機能の更新を開始します。

この関数は、操作が完了するまで無期限に待機できる実行時間の長い操作ポーリング ツールを返します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  PhoneNumberCapabilitiesRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumberToUpdate = "<phone-number-to-update>";

// This will update phone number to send and receive sms, but only send calls.
const updateRequest: PhoneNumberCapabilitiesRequest = {
  sms: "inbound+outbound",
  calling: "outbound",
};

const updatePoller = await client.beginUpdatePhoneNumberCapabilities(
  phoneNumberToUpdate,
  updateRequest,
);

// Update is underway.
const { capabilities } = await updatePoller.pollUntilDone();
console.log(`These are the update capabilities: ${capabilities}`);
function beginUpdatePhoneNumberCapabilities(phoneNumber: string, request: PhoneNumberCapabilitiesRequest, options?: BeginUpdatePhoneNumberCapabilitiesOptions): Promise<PollerLike<PollOperationState<PurchasedPhoneNumber>, PurchasedPhoneNumber>>

パラメーター

phoneNumber

string

E.164 形式の電話番号が更新されます。 先頭に +を付けるか、%2Bとしてエンコードできます。

request
PhoneNumberCapabilitiesRequest

電話番号に適用される更新されたプロパティ。

options
BeginUpdatePhoneNumberCapabilitiesOptions

追加の要求オプション。

戻り値

Promise<PollerLike<@azure/core-lro.PollOperationState<PurchasedPhoneNumber>, PurchasedPhoneNumber>>

browseAvailablePhoneNumbers(BrowseAvailableNumbersRequest, BrowseAvailableNumbersOptions)

購入できる電話番号を参照します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  BrowseAvailableNumbersRequest,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const browseAvailableNumberRequest: BrowseAvailableNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
};
const browseAvailableNumbers = await client.browseAvailablePhoneNumbers(
  browseAvailableNumberRequest,
  {
    capabilities: {
      calling: "outbound",
    },
    assignmentType: "application",
  },
);
for (const phoneNumber of browseAvailableNumbers.phoneNumbers) {
  console.log("Found phone number: ", phoneNumber.phoneNumber);
}

利用可能な電話番号を閲覧する

function browseAvailablePhoneNumbers(request: BrowseAvailableNumbersRequest, options?: BrowseAvailableNumbersOptions): Promise<PhoneNumbersBrowseResult>

パラメーター

request
BrowseAvailableNumbersRequest

利用可能な電話番号を参照するためのリクエストパラメータ。

options
BrowseAvailableNumbersOptions

追加の要求オプション。

戻り値

createOrUpdateReservation(CreateOrUpdateReservationRequest, CreateOrUpdateReservationOptions)

指定された ID を持つ予約に電話番号を追加および削除します。 応答は、予約の更新された状態になります。 電話番号は、ペイロードに含めることで予約できます。 予約に既に数値が含まれている場合は無視されます。 電話番号を削除するには、要求ペイロードで明示的に null に設定します。 この操作はべき等です。 同じ ID の予約が既に存在する場合は更新され、それ以外の場合は新しい予約が作成されます。 "アクティブ" 状態の予約のみを更新できます。 予約を更新すると、予約の有効期限が最後の変更の 15 分後に延長され、作成時刻から最大 2 時間まで延長されます。 部分的な成功が可能です。この場合、応答には 207 状態コードが含まれます。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import {
  PhoneNumbersClient,
  BrowseAvailableNumbersRequest,
  AvailablePhoneNumber,
} from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const browseAvailableNumberRequest: BrowseAvailableNumbersRequest = {
  countryCode: "US",
  phoneNumberType: "tollFree",
};

const browseAvailableNumbers = await client.browseAvailablePhoneNumbers(
  browseAvailableNumberRequest,
  {
    capabilities: {
      calling: "outbound",
    },
    assignmentType: "application",
  },
);
const phoneNumbers = browseAvailableNumbers.phoneNumbers;
const phoneNumbersList = [phoneNumbers[0], phoneNumbers[1]];
const reservationResponse = await client.createOrUpdateReservation(
  {
    reservationId: "reservationId",
  },
  {
    add: phoneNumbersList,
  },
);
const numbersWithError: AvailablePhoneNumber[] = [];
for (const number of Object.values(reservationResponse.phoneNumbers || {})) {
  if (number != null && number.status === "error") {
    numbersWithError.push(number);
  }
}
if (numbersWithError.length > 0) {
  console.log("Errors occurred during reservation");
} else {
  console.log("Reservation operation completed without errors.");
}

予約を作成または更新します。

function createOrUpdateReservation(request: CreateOrUpdateReservationRequest, options?: CreateOrUpdateReservationOptions): Promise<PhoneNumbersReservation>

パラメーター

request
CreateOrUpdateReservationRequest

予約を作成または更新するための要求パラメーター。

options
CreateOrUpdateReservationOptions

オプション パラメーター。

戻り値

deleteReservation(string, DeleteReservationOptions)

予約を ID で削除します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";
await client.deleteReservation(reservationId);

console.log(`Reservation with ID ${reservationId} has been deleted.`);

予約を削除します。

function deleteReservation(reservationId: string, options?: DeleteReservationOptions): Promise<void>

パラメーター

reservationId

string

予約の ID。

options
DeleteReservationOptions

追加の要求オプション。

戻り値

Promise<void>

getPurchasedPhoneNumber(string, OperationOptions)

購入した電話番号の詳細を取得します。 電話番号、コスト、国コードなどが含まれます。

function getPurchasedPhoneNumber(phoneNumber: string, options?: OperationOptions): Promise<PurchasedPhoneNumber>

パラメーター

phoneNumber

string

フェッチされる E.164 形式の電話番号。 先頭に +を付けるか、%2Bとしてエンコードできます。

options
OperationOptions

追加の要求オプション。

戻り値

getReservation(string, GetReservationOptions)

関連付けられているすべての電話番号を含む、指定された ID を持つ予約を取得します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const reservationId = "<reservation-id>";
const reservationResponse = await client.getReservation(reservationId);

console.log(`Phone numbers in reservation: ${reservationResponse.phoneNumbers}`);

予約を取ります。

function getReservation(reservationId: string, options?: GetReservationOptions): Promise<PhoneNumbersReservation>

パラメーター

reservationId

string

予約の ID。

options
GetReservationOptions

追加の要求オプション。

戻り値

listAvailableCountries(ListAvailableCountriesOptions)

使用可能な国を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const country of client.listAvailableCountries()) {
  console.log("country: ", country.localizedName);
}

利用可能なすべての国を一覧表示します。

function listAvailableCountries(options?: ListAvailableCountriesOptions): PagedAsyncIterableIterator<PhoneNumberCountry, PhoneNumberCountry[], PageSettings>

パラメーター

options
ListAvailableCountriesOptions

省略可能なパラメーター。

戻り値

listAvailableGeographicAreaCodes(string, ListGeographicAreaCodesOptions)

使用可能な地理的エリア コードを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableGeographicAreaCodes("US")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

使用可能なすべての地域コードを一覧表示します。

function listAvailableGeographicAreaCodes(countryCode: string, options?: ListGeographicAreaCodesOptions): PagedAsyncIterableIterator<PhoneNumberAreaCode, PhoneNumberAreaCode[], PageSettings>

パラメーター

countryCode

string

ISO 3166-2 国コード。

options
ListGeographicAreaCodesOptions

省略可能なパラメーター。

戻り値

listAvailableLocalities(string, ListLocalitiesOptions)

使用可能なロケールを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const locality of client.listAvailableLocalities("US")) {
  console.log("locality: ", locality.localizedName);
}

使用可能なすべての地域を一覧表示します。

function listAvailableLocalities(countryCode: string, options?: ListLocalitiesOptions): PagedAsyncIterableIterator<PhoneNumberLocality, PhoneNumberLocality[], PageSettings>

パラメーター

countryCode

string

ISO 3166-2 国コード。

options
ListLocalitiesOptions

省略可能なパラメーター。

戻り値

listAvailableMobileAreaCodes(string, ListMobileAreaCodesOptions)

使用可能なモバイル市外局番を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableMobileAreaCodes("IE")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

利用可能なすべての携帯電話市外局番を一覧表示します。

function listAvailableMobileAreaCodes(countryCode: string, options?: ListMobileAreaCodesOptions): PagedAsyncIterableIterator<PhoneNumberAreaCode, PhoneNumberAreaCode[], PageSettings>

パラメーター

countryCode

string

ISO 3166-2 国コード。

options
ListMobileAreaCodesOptions

省略可能なパラメーター。

戻り値

listAvailableOfferings(string, ListOfferingsOptions)

使用可能なオファリングを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const offering of client.listAvailableOfferings("US")) {
  console.log("phone number type: ", offering.phoneNumberType);
  console.log("cost: ", offering.cost.amount);
}

使用可能なすべてのオファリングを一覧表示します。

function listAvailableOfferings(countryCode: string, options?: ListOfferingsOptions): PagedAsyncIterableIterator<PhoneNumberOffering, PhoneNumberOffering[], PageSettings>

パラメーター

countryCode

string

ISO 3166-2 国コード。

options
ListOfferingsOptions

省略可能なパラメーター。

戻り値

listAvailableTollFreeAreaCodes(string, ListTollFreeAreaCodesOptions)

使用可能な Toll-Free 面コードを反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const areaCodeItem of client.listAvailableTollFreeAreaCodes("US")) {
  console.log("area code: ", areaCodeItem.areaCode);
}

使用可能なすべての Toll-Free エリア コードを一覧表示します。

function listAvailableTollFreeAreaCodes(countryCode: string, options?: ListTollFreeAreaCodesOptions): PagedAsyncIterableIterator<PhoneNumberAreaCode, PhoneNumberAreaCode[], PageSettings>

パラメーター

countryCode

string

ISO 3166-2 国コード。

options
ListTollFreeAreaCodesOptions

省略可能なパラメーター。

戻り値

listPurchasedPhoneNumbers(ListPurchasedPhoneNumbersOptions)

購入した電話番号を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

const phoneNumbers = client.listPurchasedPhoneNumbers();

for await (const phoneNumber of phoneNumbers) {
  console.log(`The id is the same as the phone number: ${phoneNumber.id}`);
  console.log(`Phone number type is ${phoneNumber.phoneNumberType}`);
}

購入したすべての電話番号を一覧表示します。

function listPurchasedPhoneNumbers(options?: ListPurchasedPhoneNumbersOptions): PagedAsyncIterableIterator<PurchasedPhoneNumber, PurchasedPhoneNumber[], PageSettings>

パラメーター

options
ListPurchasedPhoneNumbersOptions

省略可能なパラメーター。

戻り値

listReservations(ListReservationOptions)

すべての電話番号の予約を反復処理します。

使用例:

import { DefaultAzureCredential } from "@azure/identity";
import { PhoneNumbersClient } from "@azure/communication-phone-numbers";

const credential = new DefaultAzureCredential();
const client = new PhoneNumbersClient("<endpoint-from-resource>", credential);

for await (const reservation of client.listReservations()) {
  console.log(`Reservation id: ${reservation.id}`);
}

すべての電話番号の予約をリストします。 予約には、関連付けられている電話番号は入力されません。

function listReservations(options?: ListReservationOptions): PagedAsyncIterableIterator<PhoneNumbersReservation, PhoneNumbersReservation[], PageSettings>

パラメーター

options
ListReservationOptions

省略可能なパラメーター。

戻り値

searchOperatorInformation(string[], SearchOperatorInformationOptions)

指定した電話番号に関するオペレーター情報を検索します。

function searchOperatorInformation(phoneNumbers: string[], options?: SearchOperatorInformationOptions): Promise<OperatorInformationResult>

パラメーター

phoneNumbers

string[]

検索する電話番号。

options
SearchOperatorInformationOptions

追加の要求オプション。

戻り値