Skip to content

Commit

Permalink
PHONUM-2815 (#303)
Browse files Browse the repository at this point in the history
* added buy number change

* cnam lookup in update api

* buy done

* sync with master logic

* bump version

---------

Co-authored-by: kalyan-plivo <[email protected]>
  • Loading branch information
prabhav-plivo and kalyan-plivo authored Jun 2, 2023
1 parent 3964bce commit 248d8b3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [4.49.0](https://github.com/plivo/plivo-node/tree/v4.49.0) (2023-06-02)
**Feature - CNAM Lookup**
- Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API]
- Added `cnam_lookup` filter to AccountPhoneNumber - list all my numbers API.
- Added `cnam_lookup` parameter to buy number[Buy a Phone Number] to configure CNAM Lookup while buying a US number
- Added `cnam_lookup` parameter to update number[Update an account phone number] to configure CNAM Lookup while buying a US number

## [4.48.0](https://github.com/plivo/plivo-node/tree/v4.43.1) (2023-03-16)
**Feature : Adding new param in getCallDetails API**
- Added CNAM (Caller_id Name) details at CDR level.
Expand Down
27 changes: 18 additions & 9 deletions lib/resources/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ const idField = 'number';


export class BuyNumberResponse {
constructor(params) {
constructor(params, statusCode) {
params = params || {};
this.apiId = params.apiId;
this.numbers = params.numbers;
this.status = params.status;

this.message = params.message;
this.statusCode = statusCode;
}
}

Expand Down Expand Up @@ -77,13 +78,14 @@ export class PhoneNumber extends PlivoResource {
* Buy Phone Number
* @method
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number,appId) {
buy(number,appId,cnamLookup) {
return new PhoneNumberInterface(this[clientKey], {
id: this.id
}).buy(number,appId);
}).buy(number,appId,cnamLookup);
}
}

Expand All @@ -106,20 +108,24 @@ export class PhoneNumberInterface extends PlivoResourceInterface {
* Buy Phone Number
* @method
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
buy(number, appId,cnamLookup) {
let params = {};
if (appId) {
params.app_id = appId;
}
if (cnamLookup) {
params.cnam_lookup = cnamLookup;
}
let client = this[clientKey];

return new Promise((resolve, reject) => {
client('POST', 'PhoneNumber/' + number + '/', params)
.then(response => {
resolve(new BuyNumberResponse(response.body, idField));
resolve(new BuyNumberResponse(response.body, response.response.status, idField));
})
.catch(error => {
reject(error);
Expand Down Expand Up @@ -172,6 +178,7 @@ export class NumberResource extends PlivoResource {
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @param {string} [params.cnamLookup] - cnam lookup of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
Expand Down Expand Up @@ -217,10 +224,11 @@ export class NumberInterface extends PlivoResourceInterface {
* @method
* @param {string} number - number to buy
* @param {string} appId - app id
* @param {string} cnamLookup - cnam lookup
* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success
* @fail {Error} return Error
*/
buy(number, appId) {
buy(number, appId, cnamLookup) {
let errors = validate([{
field: 'number',
value: number,
Expand All @@ -232,7 +240,7 @@ export class NumberInterface extends PlivoResourceInterface {
}
return new PhoneNumber(this[clientKey], {
id: number
}).buy(number, appId);
}).buy(number, appId, cnamLookup);
}

/**
Expand Down Expand Up @@ -271,7 +279,7 @@ export class NumberInterface extends PlivoResourceInterface {
params.numbers = numbers;
params.carrier = carrier;
params.region = region;

let client = this[clientKey];
return new Promise((resolve, reject) => {
client('POST', action, params)
Expand Down Expand Up @@ -316,6 +324,7 @@ export class NumberInterface extends PlivoResourceInterface {
* @param {string} [params.appId] - app id
* @param {string} [params.subAccount] - auth_id of subaccount
* @param {string} [params.alias] - textual name of number
* @param {string} [params.cnamLookup] - cnam lookup of number
* @promise {@link NumberResource} return NumberResource Object if success
* @fail {Error} return Error
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plivo",
"version": "4.48.0",
"version": "4.49.0",
"description": "A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML",
"homepage": "https://github.com/plivo/plivo-node",
"files": [
Expand Down

0 comments on commit 248d8b3

Please sign in to comment.