Skip to content

Commit

Permalink
Merge pull request #55 from Bandwidth/DX-2448
Browse files Browse the repository at this point in the history
DX-2448 Add moveTns API Endpoints
  • Loading branch information
ajrice6713 authored Mar 1, 2022
2 parents 452815d + 7d01e8b commit e09e532
Show file tree
Hide file tree
Showing 5 changed files with 1,467 additions and 11 deletions.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NodeJs Client library for Bandwidth Numbers API

## Developer Docs
* [[Bandwidth API Developer Docs](https://dev.bandwidth.com)
* [Bandwidth API Developer Docs](https://dev.bandwidth.com)

## Other Node SDKs
* Messaging: https://github.com/Bandwidth/node-messaging
Expand Down Expand Up @@ -150,6 +150,42 @@ Each entity has a get, list, create, update and delete method if appropriate.
All properties are camel-cased for Javascript readability, and are converted on the fly to the proper
case by the internals of the API when converted to XML.

## Account
### Get Move Tns Orders

```js
var orders = numbers.Account.getMoveTnsOrders(function(err, res){
if (err){
console.log(err)
};
console.log(res);
});
```

### Create Move Tns Order

```js
numbers = ["19195551234", "19195554321"]
data = {
CustomerOrderId: "abc123",
SiteId: "12345", // DESTINATION sub-account (site)
SipPeerId: "54321" // DESTINATION location (sip-peer) (optional - if not inclided, tn(s) will provision to default sip-peer)
}
data.telephoneNumbers = [numbers.map(number => {return {telephoneNumber: number}})];
numbers.account.moveTns(client, data, callback);
```

### Get Move Tns Order Information

```js
numbers.account.getMoveTnsOrder(client, 'my-order-id-12345', callback);
```

### Get Move Tns Order History

```js
numbers.account.getMoveTnsOrderHistory(client, 'my-order-id-12345', callback);
```

## Applications
### Create Voice Application
Expand Down
56 changes: 56 additions & 0 deletions lib/account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Client = require("./client");
var MOVE_TNS_PATH = "moveTns";

module.exports = {
get: function(client, callback){
Expand All @@ -25,5 +26,60 @@ module.exports = {
}
callback(null, res.products);
});
},

getMoveTnsOrders: function(client, callback) {
if(arguments.length === 1){
callback = client;
client = new Client();
}
client.makeRequest("get", client.concatAccountPath("moveTns"), function(err,res){
if(err){
return callback(err);
}
callback(null, res);
});
},

moveTns: function(client, item, callback) {
if(arguments.length === 2){
item = client;
callback = item;
client = new Client();
}
client.makeRequest("post", client.concatAccountPath(MOVE_TNS_PATH), {moveTnsOrder: item}, function(err, res){
if(err){
return callback(err, res);
}
callback(null, res);
});
},

getMoveTnsOrder: function(client, id, callback) {
if(arguments.length === 2){
id = client;
callback = id;
client = new Client();
}
client.makeRequest("get", client.concatAccountPath("moveTns") + "/" + id, function(err,res){
if(err){
return callback(err);
}
callback(null, res);
});
},

getMoveTnsOrderHistory: function(client, id, callback) {
if(arguments.length === 2){
id = client;
callback = id;
client = new Client();
}
client.makeRequest("get", client.concatAccountPath("moveTns")+ "/" + id + "/history", function(err,res){
if(err){
return callback(err);
}
callback(null, res);
});
}
}
Loading

0 comments on commit e09e532

Please sign in to comment.