مشاركة عبر


PhoneNumbersClient class

فئة العميل للتفاعل مع إدارة رقم هاتف Azure Communication Services.

المنشئون

PhoneNumbersClient(string, KeyCredential, PhoneNumbersClientOptions)

تهيئة مثيل جديد من فئة PhoneNumberAdministrationClient باستخدام Azure KeyCredential.

PhoneNumbersClient(string, PhoneNumbersClientOptions)

تهيئة مثيل جديد من فئة PhoneNumberAdministrationClient باستخدام سلسلة اتصال.

PhoneNumbersClient(string, TokenCredential, PhoneNumbersClientOptions)

تهيئة مثيل جديد من فئة PhoneNumberAdministrationClient باستخدام TokenCredential.

الأساليب

beginPurchasePhoneNumbers(string, BeginPurchasePhoneNumbersOptions)

يبدأ شراء رقم (أرقام) الهاتف في البحث المقترن بمعرف معين.

تقوم هذه الدالة بإرجاع استقصاء عملية طويلة الأمد التي تسمح لك بالانتظار إلى أجل غير مسمى حتى تكتمل العملية.

مثال على الاستخدام:

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)

يبدأ شراء رقم (أرقام) الهاتف في البحث المقترن بمعرف معين.

تقوم هذه الدالة بإرجاع استقصاء عملية طويلة الأمد التي تسمح لك بالانتظار إلى أجل غير مسمى حتى تكتمل العملية.

مثال على الاستخدام:

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}`);

يبدأ شراء أرقام الهواتف في الحجز باستخدام بطاقة الهوية المحددة.

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)

يضيف ويزيله أرقام الهواتف من الحجز باستخدام المعرف المحدد. سيكون الرد هو الحالة المحدثة للحجز. يمكن حجز أرقام الهواتف عن طريق تضمينها في الحمولة. إذا كان الرقم موجودا بالفعل في الحجز ، تجاهله. لإزالة رقم هاتف، قم بتعيينه بشكل صريح إلى null في حمولة الطلب. هذه العملية متكررة. إذا كان هناك حجز بنفس المعرف موجودا بالفعل، تحديثه، وإلا يتم إنشاء حجز جديد. يمكن تحديث الحجوزات ذات الحالة "النشطة" فقط. سيؤدي تحديث الحجز إلى تمديد وقت انتهاء صلاحية الحجز إلى 15 دقيقة بعد آخر تغيير، بحد أقصى ساعتين من وقت الإنشاء. النجاح الجزئي ممكن ، وفي هذه الحالة سيكون للاستجابة رمز حالة 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)

حذف الحجز بمعرفه.

مثال على الاستخدام:

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)

يسترجع الحجز باستخدام المعرف المحدد، بما في ذلك جميع أرقام الهواتف المرتبطة به.

مثال على الاستخدام:

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)

تهيئة مثيل جديد من فئة PhoneNumberAdministrationClient باستخدام Azure KeyCredential.

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. (على سبيل المثال: نقطة النهاية=https://contoso.eastus.communications.azure.net/; مفتاح الوصول =سري)

options
PhoneNumbersClientOptions

اختياري. خيارات لتكوين البنية الأساسية لبرنامج ربط العمليات التجارية HTTP.

PhoneNumbersClient(string, TokenCredential, PhoneNumbersClientOptions)

تهيئة مثيل جديد من فئة PhoneNumberAdministrationClient باستخدام TokenCredential.

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)

يبدأ شراء رقم (أرقام) الهاتف في البحث المقترن بمعرف معين.

تقوم هذه الدالة بإرجاع استقصاء عملية طويلة الأمد التي تسمح لك بالانتظار إلى أجل غير مسمى حتى تكتمل العملية.

مثال على الاستخدام:

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

معرف البحث المراد شراؤه. تم إرجاعه من 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)

يبدأ شراء رقم (أرقام) الهاتف في البحث المقترن بمعرف معين.

تقوم هذه الدالة بإرجاع استقصاء عملية طويلة الأمد التي تسمح لك بالانتظار إلى أجل غير مسمى حتى تكتمل العملية.

مثال على الاستخدام:

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}`);

يبدأ شراء أرقام الهواتف في الحجز باستخدام بطاقة الهوية المحددة.

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

المعلمات

reservationId

string

معرف الحجز.

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)

يضيف ويزيله أرقام الهواتف من الحجز باستخدام المعرف المحدد. سيكون الرد هو الحالة المحدثة للحجز. يمكن حجز أرقام الهواتف عن طريق تضمينها في الحمولة. إذا كان الرقم موجودا بالفعل في الحجز ، تجاهله. لإزالة رقم هاتف، قم بتعيينه بشكل صريح إلى null في حمولة الطلب. هذه العملية متكررة. إذا كان هناك حجز بنفس المعرف موجودا بالفعل، تحديثه، وإلا يتم إنشاء حجز جديد. يمكن تحديث الحجوزات ذات الحالة "النشطة" فقط. سيؤدي تحديث الحجز إلى تمديد وقت انتهاء صلاحية الحجز إلى 15 دقيقة بعد آخر تغيير، بحد أقصى ساعتين من وقت الإنشاء. النجاح الجزئي ممكن ، وفي هذه الحالة سيكون للاستجابة رمز حالة 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)

حذف الحجز بمعرفه.

مثال على الاستخدام:

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

معرف الحجز.

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)

يسترجع الحجز باستخدام المعرف المحدد، بما في ذلك جميع أرقام الهواتف المرتبطة به.

مثال على الاستخدام:

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

معرف الحجز.

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

خيارات طلب إضافية.

المرتجعات