From 23fbb1fe423a8b9e564d50bce66ea6ccf11b1262 Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Fri, 1 Apr 2022 16:29:19 +0530 Subject: [PATCH 1/3] add methods for 10dlc number linking --- lib/resources/campaign.js | 82 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/lib/resources/campaign.js b/lib/resources/campaign.js index 6e240b6a..5879e85a 100644 --- a/lib/resources/campaign.js +++ b/lib/resources/campaign.js @@ -45,6 +45,19 @@ export class CampaignCreateResponse { } } +export class LinkUnlinkNumberResponse { + constructor(params) { + params = params || {}; + this.apiId = params.apiId; + if (params.message) + this.message = params.message; + if (params.error) + this.error = params.error; + if (params.remark) + this.remark = params.remark; + } +} + /** * Represents a Campaign Interface * @constructor @@ -84,7 +97,6 @@ export class CampaignCreateResponse { return super.customexecuteAction(action,'GET', params); } - /** * create Campaign * @method @@ -133,7 +145,75 @@ export class CampaignCreateResponse { reject(error); }); }); + } + + /** + * getNumber CampaignNumbers by given campaignId, number + * @method + * @param {string} campaignID - id of Campaign + * @param {string} number - number + * @promise {object} return {@link Campaign} object + * @fail {Error} return Error + */ + getNumber(campaignID, number) { + return super.customexecuteAction(action+campaignID+'/Number/'+number+'/', 'GET'); + } + /** + * listNumber CampaignNumbers by given campaignId + * @method + * @param {string} campaignID - id of Campaign + * @param {number} limit + * @param {number} offset + * @promise {object} returns {@link Campaign} object + * @fail {Error} return Error + */ + listNumber(campaignID, limit=10, offset=0) { + return super.customexecuteAction(action+campaignID+'/Number/?limit='+limit+'&offset='+offset, 'GET'); + } + + /** + * linkNumber link number to Campaign + * @method + * @param {string} campaignID + * @param {string} number + * @promise {object} return {@link Campaign} object + * @fail {Error} return Error + */ + linkNumber(campaignID, number) { + let params = {} + params.number=number; + let client = this[clientKey]; + return new Promise((resolve, reject) => { + client('POST', action+campaignID+'/Number/', params) + .then(response => { + resolve(new LinkUnlinkNumberResponse(response.body)); + }) + .catch(error => { + reject(error); + }); + }); } + /** + * unlinkNumber unlink number from Campaign + * @method + * @param {string} campaignID + * @param {string} number + * @promise {object} return {@link Campaign} object + * @fail {Error} return Error + */ + unlinkNumber(campaignID, number) { + let params = {} + let client = this[clientKey]; + return new Promise((resolve, reject) => { + client('DELETE', action+campaignID+'/Number/'+number+'/', params) + .then(response => { + resolve(new LinkUnlinkNumberResponse(response.body)); + }) + .catch(error => { + reject(error); + }); + }); + } } \ No newline at end of file From 57cf09c0a5193dea694642eb34e9db20fcdc8dfa Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Wed, 13 Apr 2022 15:17:42 +0530 Subject: [PATCH 2/3] update linkNumber req payload --- lib/resources/campaign.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/resources/campaign.js b/lib/resources/campaign.js index 5879e85a..7256cc89 100644 --- a/lib/resources/campaign.js +++ b/lib/resources/campaign.js @@ -176,13 +176,13 @@ export class LinkUnlinkNumberResponse { * linkNumber link number to Campaign * @method * @param {string} campaignID - * @param {string} number + * @param {list} numbers * @promise {object} return {@link Campaign} object * @fail {Error} return Error */ - linkNumber(campaignID, number) { + linkNumber(campaignID, numbers) { let params = {} - params.number=number; + params.numbers=numbers; let client = this[clientKey]; return new Promise((resolve, reject) => { client('POST', action+campaignID+'/Number/', params) From 8c5d6b49a990f088815d31ea21fd095bf18990d7 Mon Sep 17 00:00:00 2001 From: narayana Date: Thu, 14 Apr 2022 12:08:50 +0530 Subject: [PATCH 3/3] fixing list number --- lib/resources/campaign.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/resources/campaign.js b/lib/resources/campaign.js index 7256cc89..15768b44 100644 --- a/lib/resources/campaign.js +++ b/lib/resources/campaign.js @@ -168,8 +168,8 @@ export class LinkUnlinkNumberResponse { * @promise {object} returns {@link Campaign} object * @fail {Error} return Error */ - listNumber(campaignID, limit=10, offset=0) { - return super.customexecuteAction(action+campaignID+'/Number/?limit='+limit+'&offset='+offset, 'GET'); + listNumber(campaignID, params) { + return super.customexecuteAction(action+campaignID+'/Number/', 'GET', params); } /**