From b158429c85b99d874d73a1f2f8bb0d9a8d6d79cf Mon Sep 17 00:00:00 2001 From: Nalin Abrol Date: Thu, 20 Feb 2020 12:30:24 +0530 Subject: [PATCH 1/5] changes made --- lib/resources/powerpacks.js | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/lib/resources/powerpacks.js b/lib/resources/powerpacks.js index 71c9cac4..d13ac8ef 100644 --- a/lib/resources/powerpacks.js +++ b/lib/resources/powerpacks.js @@ -98,6 +98,12 @@ export class Powerpack extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Number/' + number + '/'; return super.customexecuteAction(path.toString().trim(), 'POST', params); } + add_number(tollfree) { + var params = {}; + params['rent'] = 'false'; + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'POST', params); + } remove_number(number, unrent = false) { var params = {}; if (typeof unrent === 'boolean') { @@ -108,6 +114,20 @@ export class Powerpack extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Number/' + number + '/'; return super.customexecuteAction(path.toString().trim(), 'DELETE', params); } + remove_tollfree(tollfree, unrent = false) { + var params = {}; + if (typeof unrent === 'boolean') { + params['unrent'] = unrent.toString(); + } else { + params['unrent'] = unrent; + } + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'DELETE', params); + } + remove_shortcode(shortcode) { + let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/' + shortcode + '/'; + return super.customexecuteAction(path.toString().trim(), 'DELETE'); + } list_shortcodes(params) { if (params === undefined) { params = {}; @@ -115,10 +135,21 @@ export class Powerpack extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/'; return super.customexecuteAction(path.toString().trim(), 'GET', params); } + list_tollfrees(params) { + if (params === undefined) { + params = {}; + } + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/'; + return super.customexecuteAction(path.toString().trim(), 'GET', params); + } find_shortcode(shortcode) { let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/' + shortcode + '/'; return super.customexecuteAction(path.toString().trim(), 'GET'); } + find_tollfree(tollfree) { + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'GET'); + } buy_add_number(params) { var number = params.number; var rentparam = {}; @@ -312,6 +343,44 @@ export class Shortcode extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/' + shortcode + '/'; return super.customexecuteAction(path.toString().trim(), 'GET'); } + remove(shortcode) { + let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/' + shortcode + '/'; + return super.customexecuteAction(path.toString().trim(), 'DELETE'); + } +} +export class Tollfree extends PlivoResource { + constructor(client, data = {}) { + super(action, Tollfree, numberPoolField, client); + extend(this, data); + this.number_pool_id = data.number_pool_id; + } + add(tollfree) { + var params = {}; + params['rent'] = 'false'; + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'POST', params); + } + remove(number, unrent = false) { + var params = {}; + if (typeof unrent === 'boolean') { + params['unrent'] = unrent.toString(); + } else { + params['unrent'] = unrent; + } + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'DELETE', params); + } + list(params) { + if (params === undefined) { + params = {}; + } + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/'; + return super.customexecuteAction(path.toString().trim(), 'GET', params); + } + find(tollfree) { + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + Tollfree + '/'; + return super.customexecuteAction(path.toString().trim(), 'GET'); + } } /** * Represents a Powerpack interface From 8b6031897c859b6198c3a167b212fb098c3eea46 Mon Sep 17 00:00:00 2001 From: abrolnalin Date: Thu, 5 Mar 2020 11:18:28 +0530 Subject: [PATCH 2/5] changes made --- lib/resources/powerpacks.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/resources/powerpacks.js b/lib/resources/powerpacks.js index d13ac8ef..2c64b0d4 100644 --- a/lib/resources/powerpacks.js +++ b/lib/resources/powerpacks.js @@ -98,7 +98,7 @@ export class Powerpack extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Number/' + number + '/'; return super.customexecuteAction(path.toString().trim(), 'POST', params); } - add_number(tollfree) { + add_tollfree(tollfree) { var params = {}; params['rent'] = 'false'; let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; @@ -135,7 +135,7 @@ export class Powerpack extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Shortcode/'; return super.customexecuteAction(path.toString().trim(), 'GET', params); } - list_tollfrees(params) { + list_tollfree(params) { if (params === undefined) { params = {}; } @@ -215,6 +215,9 @@ export class NumberPool extends PlivoResource { this.shortcodes = new Shortcode(client, { number_pool_id: data.number_pool_id }); + this.tollfree = new Tollfree(client, { + number_pool_id: data.number_pool_id + }); extend(this, data); } @@ -360,7 +363,7 @@ export class Tollfree extends PlivoResource { let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; return super.customexecuteAction(path.toString().trim(), 'POST', params); } - remove(number, unrent = false) { + remove(tollfree, unrent = false) { var params = {}; if (typeof unrent === 'boolean') { params['unrent'] = unrent.toString(); @@ -378,7 +381,7 @@ export class Tollfree extends PlivoResource { return super.customexecuteAction(path.toString().trim(), 'GET', params); } find(tollfree) { - let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + Tollfree + '/'; + let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; return super.customexecuteAction(path.toString().trim(), 'GET'); } } From ff036549a45015c118ed4c896f1eb437ae806b6e Mon Sep 17 00:00:00 2001 From: abrolnalin Date: Mon, 23 Mar 2020 16:43:32 +0530 Subject: [PATCH 3/5] mend --- CHANGELOG.md | 3 +++ lib/resources/powerpacks.js | 24 ++++--------------- package.json | 2 +- test/powerpacks.js | 47 +++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c956c5d2..06619355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [4.2.1](https://github.com/plivo/plivo-node/releases/tag/v4.2.1)(2020-03-25) +- Add Tollfree support for Powerpack + ## [4.1.9](https://github.com/plivo/plivo-node/releases/tag/v4.1.9)(2020-02-12) - Fix end_time_gte param in Retrieve a call API. diff --git a/lib/resources/powerpacks.js b/lib/resources/powerpacks.js index 2c64b0d4..e2706e04 100644 --- a/lib/resources/powerpacks.js +++ b/lib/resources/powerpacks.js @@ -106,21 +106,13 @@ export class Powerpack extends PlivoResource { } remove_number(number, unrent = false) { var params = {}; - if (typeof unrent === 'boolean') { - params['unrent'] = unrent.toString(); - } else { - params['unrent'] = unrent; - } + params['unrent'] = unrent.toString(); let path = 'NumberPool/' + this.number_pool_id + '/Number/' + number + '/'; return super.customexecuteAction(path.toString().trim(), 'DELETE', params); } remove_tollfree(tollfree, unrent = false) { var params = {}; - if (typeof unrent === 'boolean') { - params['unrent'] = unrent.toString(); - } else { - params['unrent'] = unrent; - } + params['unrent'] = unrent.toString(); let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; return super.customexecuteAction(path.toString().trim(), 'DELETE', params); } @@ -320,11 +312,7 @@ export class Numbers extends PlivoResource { } remove(number, unrent = false) { var params = {}; - if (typeof unrent === 'boolean') { - params['unrent'] = unrent.toString(); - } else { - params['unrent'] = unrent; - } + params['unrent'] = unrent.toString(); let path = 'NumberPool/' + this.number_pool_id + '/Number/' + number + '/'; return super.customexecuteAction(path.toString().trim(), 'DELETE', params); } @@ -365,11 +353,7 @@ export class Tollfree extends PlivoResource { } remove(tollfree, unrent = false) { var params = {}; - if (typeof unrent === 'boolean') { - params['unrent'] = unrent.toString(); - } else { - params['unrent'] = unrent; - } + params['unrent'] = unrent.toString(); let path = 'NumberPool/' + this.number_pool_id + '/Tollfree/' + tollfree + '/'; return super.customexecuteAction(path.toString().trim(), 'DELETE', params); } diff --git a/package.json b/package.json index feaf2ca9..1774072e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.1.9", + "version": "4.2.1", "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": [ diff --git a/test/powerpacks.js b/test/powerpacks.js index 99566464..a7cc8973 100644 --- a/test/powerpacks.js +++ b/test/powerpacks.js @@ -87,5 +87,52 @@ describe('PowerpackInterface', function () { assert.notEqual(result.length, 0) }) }); + it('list tollfree via interface', function () { + client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( + function (powerpack) { + return powerpack.list_tollfree() + }) + .then(function (result) { + assert.notEqual(result.length, 0) + }) + }); + it('find tollfree via interface', function () { + client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( + function (powerpack) { + return powerpack.find_tollfree('18772209942') + }) + .then(function (result) { + assert.Equal(result.number, "18772209942") + }) + }); + it('add tollfree to powerpack via interface', function () { + client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( + function (powerpack) { + return powerpack.add_tollfree('18772209942') + }) + .then(function (result) { + assert.Equal(result.number, "18772209942") + }) + }); + it('remove tollfree via interface', function () { + client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( + function (powerpack) { + return powerpack.remove_tollfree("18772209942", true) + }) + .then(function (result) { + assert.notEqual(result.response, "success") + }) + }); + + it('remove shortcode via interface', function () { + client.powerpacks.get("5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46").then( + function (powerpack) { + return powerpack.remove_shortcode("444444") + }) + .then(function (result) { + assert.notEqual(result.response, "success") + }) + }); }); + From 3756fdfa9506a9f64678fb1266c817fac80dbff2 Mon Sep 17 00:00:00 2001 From: abrolnalin Date: Mon, 30 Mar 2020 14:51:33 +0530 Subject: [PATCH 4/5] changes made --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 206b7c0f..2ba2803c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.2.1](https://github.com/plivo/plivo-node/releases/tag/v4.2.1)(2020-03-25) +## [4.3.1](https://github.com/plivo/plivo-node/releases/tag/v4.3.1)(2020-03-30) - Add Tollfree support for Powerpack diff --git a/package.json b/package.json index 1774072e..d9e30adc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.2.1", + "version": "4.3.1", "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": [ From 86ab9b2711bb3bd2c9214607f8a678734b6bf475 Mon Sep 17 00:00:00 2001 From: nixonsamuel Date: Mon, 30 Mar 2020 16:38:17 +0530 Subject: [PATCH 5/5] bump version to 4.4.0 --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13b8693e..96dcb77b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.3.1](https://github.com/plivo/plivo-node/releases/tag/v4.3.1)(2020-03-30) +## [4.4.0](https://github.com/plivo/plivo-node/releases/tag/v4.4.0)(2020-03-30) - Add Tollfree support for Powerpack ## [4.3.0](https://github.com/plivo/plivo-node/releases/tag/v4.3.0)(2020-03-27) diff --git a/package.json b/package.json index d9e30adc..62152836 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plivo", - "version": "4.3.1", + "version": "4.4.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": [