From db33c0e4a534347515a54922aa9746647d9e7b72 Mon Sep 17 00:00:00 2001 From: prabhav-plivo Date: Wed, 26 Jul 2023 14:52:52 +0530 Subject: [PATCH 1/5] added cnam-storage changes --- lib/resources/numbers.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index 0d613efc..43c27335 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -53,6 +53,8 @@ export class UpdateNumberResponse { params = params || {}; this.apiId = params.apiId; this.message = params.message; + this.new_cnam = params.new_cnam; + this.cnam_update_status = params.cnam_update_status; } } @@ -79,13 +81,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 +114,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 +127,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 +195,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 +244,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 +262,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 +347,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 */ From 9548bd6685844569db1f8fc74de8b0ace15bff69 Mon Sep 17 00:00:00 2001 From: prabhav-plivo Date: Mon, 31 Jul 2023 14:22:10 +0530 Subject: [PATCH 2/5] removed extra keys in update response --- lib/resources/numbers.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index 43c27335..1cdfbd87 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -53,8 +53,6 @@ export class UpdateNumberResponse { params = params || {}; this.apiId = params.apiId; this.message = params.message; - this.new_cnam = params.new_cnam; - this.cnam_update_status = params.cnam_update_status; } } From 5ff4c8def1495fdb0b33cdfd1b50ef35ad63f893 Mon Sep 17 00:00:00 2001 From: prabhav-plivo Date: Wed, 2 Aug 2023 15:54:03 +0530 Subject: [PATCH 3/5] handled null scene --- lib/resources/numbers.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index 1cdfbd87..fde48a1c 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -15,12 +15,19 @@ const idField = 'number'; export class BuyNumberResponse { constructor(params, statusCode) { + console.log(params) params = params || {}; this.apiId = params.apiId; this.numbers = params.numbers; this.status = params.status; this.message = params.message; this.statusCode = statusCode; + if (params.newCnam !== undefined) { + this.new_cnam = params.newCnam; + } + if (params.cnamUpdateStatus !== undefined) { + this.cnam_update_status = params.cnamUpdateStatus; + } } } @@ -53,6 +60,12 @@ export class UpdateNumberResponse { params = params || {}; this.apiId = params.apiId; this.message = params.message; + if (params.newCnam !== undefined) { + this.new_cnam = params.newCnam; + } + if (params.cnamUpdateStatus !== undefined) { + this.cnam_update_status = params.cnamUpdateStatus; + } } } From d8aae8689b60215b97b7808bf9d22f1bce95a9f7 Mon Sep 17 00:00:00 2001 From: prabhav-plivo Date: Wed, 2 Aug 2023 16:06:35 +0530 Subject: [PATCH 4/5] removed extra console.log --- lib/resources/numbers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index fde48a1c..d73b24a6 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -15,7 +15,6 @@ const idField = 'number'; export class BuyNumberResponse { constructor(params, statusCode) { - console.log(params) params = params || {}; this.apiId = params.apiId; this.numbers = params.numbers; From 5cd0d17c6e834b6cc42e330b96aa00651d78bfe9 Mon Sep 17 00:00:00 2001 From: prabhav-plivo Date: Thu, 3 Aug 2023 18:55:54 +0530 Subject: [PATCH 5/5] clean if condition --- lib/resources/numbers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/resources/numbers.js b/lib/resources/numbers.js index d73b24a6..1b78290b 100644 --- a/lib/resources/numbers.js +++ b/lib/resources/numbers.js @@ -21,10 +21,10 @@ export class BuyNumberResponse { this.status = params.status; this.message = params.message; this.statusCode = statusCode; - if (params.newCnam !== undefined) { + if (params.newCnam) { this.new_cnam = params.newCnam; } - if (params.cnamUpdateStatus !== undefined) { + if (params.cnamUpdateStatus) { this.cnam_update_status = params.cnamUpdateStatus; } } @@ -59,10 +59,10 @@ export class UpdateNumberResponse { params = params || {}; this.apiId = params.apiId; this.message = params.message; - if (params.newCnam !== undefined) { + if (params.newCnam) { this.new_cnam = params.newCnam; } - if (params.cnamUpdateStatus !== undefined) { + if (params.cnamUpdateStatus) { this.cnam_update_status = params.cnamUpdateStatus; } }