diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index 0d613efc..1b78290b 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -21,6 +21,12 @@ export class BuyNumberResponse { this.status = params.status; this.message = params.message; this.statusCode = statusCode; + if (params.newCnam) { + this.new_cnam = params.newCnam; + } + if (params.cnamUpdateStatus) { + this.cnam_update_status = params.cnamUpdateStatus; + } } } @@ -53,6 +59,12 @@ export class UpdateNumberResponse { params = params || {}; this.apiId = params.apiId; this.message = params.message; + if (params.newCnam) { + this.new_cnam = params.newCnam; + } + if (params.cnamUpdateStatus) { + this.cnam_update_status = params.cnamUpdateStatus; + } } } @@ -79,13 +91,16 @@ export class PhoneNumber extends PlivoResource { * @method * @param {string} appId - app id * @param {string} cnamLookup - cnam lookup + * @param {string} cnam - cnam attached to number + * @param {string} callback_method - callback_method Method to call the url for attaching cnam + * @param {string} callback_url - callback_url url to attach the cnam * @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success * @fail {Error} return Error */ - buy(number,appId,cnamLookup) { + buy(number,appId,cnamLookup,cnam,callback_method,callback_url) { return new PhoneNumberInterface(this[clientKey], { id: this.id - }).buy(number,appId,cnamLookup); + }).buy(number,appId,cnamLookup,cnam,callback_method,callback_url); } } @@ -109,10 +124,12 @@ export class PhoneNumberInterface extends PlivoResourceInterface { * @method * @param {string} appId - app id * @param {string} cnamLookup - cnam lookup - * @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success + * @param {string} cnam - cnam attached to number + * @param {string} callback_method - callback_method Method to call the url for attaching cnam + * @param {string} callback_url - callback_url url to attach the cnam* @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success * @fail {Error} return Error */ - buy(number, appId,cnamLookup) { + buy(number, appId,cnamLookup, cnam, callback_method, callback_url) { let params = {}; if (appId) { params.app_id = appId; @@ -120,6 +137,15 @@ export class PhoneNumberInterface extends PlivoResourceInterface { if (cnamLookup) { params.cnam_lookup = cnamLookup; } + if (cnam) { + params.cnam = cnam; + } + if (callback_url) { + params.callback_url = callback_url; + } + if (callback_method) { + params.callback_method = callback_method; + } let client = this[clientKey]; return new Promise((resolve, reject) => { @@ -179,6 +205,9 @@ export class NumberResource extends PlivoResource { * @param {string} [params.subAccount] - auth_id of subaccount * @param {string} [params.alias] - textual name of number * @param {string} [params.cnamLookup] - cnam lookup of number + * @param {string} [params.cnam] - cnam attached to number + * @param {string} [params.callback_method] - callback_method Method to call the url for attaching cnam + * @param {string} [params.callback_url] - callback_url url to attach the cnam * @promise {@link NumberResource} return NumberResource Object if success * @fail {Error} return Error */ @@ -225,10 +254,13 @@ export class NumberInterface extends PlivoResourceInterface { * @param {string} number - number to buy * @param {string} appId - app id * @param {string} cnamLookup - cnam lookup + * @param {string} cnam - cnam attached to number + * @param {string} callbackMethod - callback_method Method to call the url for attaching cnam + * @param {string} callbackUrl - callback_url url to attach the cnam * @promise {@link PlivoGenericResponse} return PlivoGenericResponse Object if success * @fail {Error} return Error */ - buy(number, appId, cnamLookup) { + buy(number, appId, cnamLookup, cnam, callbackMethod, callbackUrl ) { let errors = validate([{ field: 'number', value: number, @@ -240,7 +272,7 @@ export class NumberInterface extends PlivoResourceInterface { } return new PhoneNumber(this[clientKey], { id: number - }).buy(number, appId, cnamLookup); + }).buy(number, appId, cnamLookup, cnam, callbackMethod, callbackUrl); } /** @@ -325,6 +357,9 @@ export class NumberInterface extends PlivoResourceInterface { * @param {string} [params.subAccount] - auth_id of subaccount * @param {string} [params.alias] - textual name of number * @param {string} [params.cnamLookup] - cnam lookup of number + * @param {string} [params.cnam] - cnam attached to number + * @param {string} [params.callback_method] - callback_method Method to call the url for attaching cnam + * @param {string} [params.callback_url] - callback_url url to attach the cnam * @promise {@link NumberResource} return NumberResource Object if success * @fail {Error} return Error */