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

cnam-storage sdk changes #310

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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: 41 additions & 6 deletions lib/resources/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand All @@ -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);
}
}

Expand All @@ -109,17 +124,28 @@ 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;
}
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) => {
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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
*/
Expand Down