diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d490f4d..fa0d9d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index 49b22e8a..0d613efc 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -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; } } @@ -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); } } @@ -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); @@ -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 */ @@ -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, @@ -232,7 +240,7 @@ export class NumberInterface extends PlivoResourceInterface { } return new PhoneNumber(this[clientKey], { id: number - }).buy(number, appId); + }).buy(number, appId, cnamLookup); } /** @@ -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) @@ -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 */ diff --git a/package.json b/package.json index ed2eeb5b..187bcc57 100644 --- a/package.json +++ b/package.json @@ -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": [