Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[communication] add LROs #11713

Merged
merged 25 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions sdk/communication/communication-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,57 +179,54 @@ Fetching area codes for geographic phone plans will require the the location opt
Use the `getAreaCodes` method to get the area codes for geographic phone plans.

```typescript
const { primaryAreaCodes } = await client.getAreaCodes(
{
locationType: "selection",
countryCode: "US",
phonePlanId: "phonePlanId",
locationOptionsQueries
}
);
const { primaryAreaCodes } = await client.getAreaCodes({
locationType: "selection",
countryCode: "US",
phonePlanId: "phonePlanId",
locationOptionsQueries
});
```

#### Searching for phone numbers
#### Reserving phone numbers for purchase

Use the `createSearch` method to search for phone numbers. This method returns a `searchId` which should be used to query the status of the search.
Use the `beginReservePhoneNumbers` method to search for phone numbers and reserve them. This is a long running operation.

```typescript
const { searchId } = await client.createSearch({
const reservePoller = await client.beginReservePhoneNumbers({
name: "Phone number search 800",
description: "Search for 800 phone numbers"
phonePlanIds: ["phone-plan-id-1"],
areaCode: "800",
quantity: 1
quantity: 3
});
```

To get the results of the search use the `searchId` to call the `getSearch` method.
To get the results of the reservation, use the `pollUntilDone` method on the poller you created.

```typescript
const phoneNumberSearch = await client.getSearch(searchId);
const phoneNumberReservation = await reservePoller.pollUntilDone();
```

#### Purchasing phone numbers from a search

Use the `purchaseSearch` method to purchase the phone numbers from your search.
You can cancel the the polling and reservation by calling the `cancelOperation` method on the poller you created.

```typescript
await client.purchaseSearch(searchId);
await reservePoller.cancelOperation();
```

You also need to call the `getSearch` method to get the results of your purchase.
#### Purchasing phone numbers from a reservation

#### Cancel a phone number search

Phone numbers are reserved for 10 minutes when you create a new search. To cancel a search, and make numbers available to other users, call the `cancelSearch` method with the `searchId` of the search.
Use the `beginPurchasePhoneNumbers` method to purchase the phone numbers from your reservation. The `reservationId` returned from `beginReservePhoneNumbers` is required. `beginPurchasePhoneNumbers` is also a long running operation.

```typescript
await client.cancelSearch(searchId);
const { reservationId } = phoneNumberReservation;
const purchasePoller = await client.beginPurchasePhoneNumbers(reservationId);
```

Call the `getSearch` method to get the results.
To get the results of the purchase, use the `pollUntilDone` method on the purchase poller you created.

**Currently, you need to implement your own poller with `getSearch` to know when the search, purchase and cancel operations have reached a terminal status.**
```typescript
const results = await purchasePoller.pollUntilDone();
```

## Troubleshooting

Expand Down
2 changes: 2 additions & 0 deletions sdk/communication/communication-administration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@
"sideEffects": false,
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/communication-common": "1.0.0-beta.3",
"@azure/core-auth": "^1.1.3",
"@azure/core-http": "^1.1.6",
"@azure/core-lro": "^1.0.2",
"@azure/core-paging": "^1.1.1",
"@azure/logger": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.9",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading