Skip to content

Commit

Permalink
Merge pull request #137 from plivo/mms_powerpack_release
Browse files Browse the repository at this point in the history
Mms powerpack release
  • Loading branch information
nixonsam authored Dec 20, 2019
2 parents b3c5164 + 2a8f0bb commit c36e5ff
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [4.1.8](https://github.com/plivo/plivo-node/releases/tag/v4.1.8)(2019-12-20)
- Add Powerpack support.

## [4.1.7](https://github.com/plivo/plivo-node/releases/tag/v4.1.7)(2019-12-04)
- Add MMS support.

Expand Down
39 changes: 39 additions & 0 deletions examples/powerpacks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var Plivo = require('../dist/rest/client.js');
var client = new Plivo.Client();

var params = {
sticky_sender: true,
local_connect: true
};
// create powerpack
client.powerpacks.create("node sdk test", params).then(function (result) {
console.log(result)
});

// get powerpack
client.powerpacks.get("0166c910-1268-47c7-bf30-f5809ee843b9").then(
function (result) {
console.log(result)
});

// list powerpack
client.powerpacks.list().then(
function (result) {
console.log(result)
});
// list numbers
client.powerpacks.get("0166c910-1268-47c7-bf30-f5809ee843b9").then(
function (powerpack) {
return powerpack.list_numbers()
})
.then(function (result) {
console.log("\n============ list numbers ===========\n", result)
})
// find number
client.powerpacks.get("0166c910-1268-47c7-bf30-f5809ee843b9").then(
function (powerpack) {
return powerpack.find_number('1234')
})
.then(function (result) {
console.log("\n============ list numbers ===========\n", result)
})
41 changes: 41 additions & 0 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,47 @@ export class PlivoResource {
});
});
}
customexecuteAction(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
resolve(new PlivoGenericResponse(response.body, idField));
})
.catch(error => {
reject(error);
});
});
}
customexecuteGetNumberAction(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
let number = "";
let promise = client(method, url, params).then(response => {
number = response.body.objects[0].number;
return number;
}).catch(error => {
console.log(error);
return error;
});
return promise;
}
getMetaResponse(url, method = 'GET', params = {}) {
let client = this[clientKey];
let idField = this[idKey];
let count = 0;
return new Promise((resolve, reject) => {
client(method, url, params)
.then(response => {
count = response.body.meta.totalCount;
resolve(count);
})
.catch(error => {
reject(error);
});
});
}
}

export class PlivoResourceInterface {
Expand Down
10 changes: 2 additions & 8 deletions lib/resources/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export class Message extends PlivoResource {
deleteMedia() {
return super.executeAction(this.id + '/Media/', 'Delete', {});
}
getMedia(mediaID) {
return super.executeAction(this.id + '/Media/' + mediaID + '/', 'Get', {});
}

}
/**
* Represents a Message Interface
Expand Down Expand Up @@ -151,11 +149,7 @@ export class MessageInterface extends PlivoResourceInterface {
id: messageUUID
}).listMedia();
}
getMedia(messageUUID, mediaID) {
return new Message(this[clientKey], {
id: messageUUID
}).getMedia(mediaID);
}

deleteMedia(messageUUID) {
return new Message(this[clientKey], {
id: messageUUID
Expand Down
Loading

0 comments on commit c36e5ff

Please sign in to comment.