Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bandwidth/numbers

Package Overview
Dependencies
Maintainers
15
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bandwidth/numbers - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

lib/application.js

2

lib/client.js

@@ -137,3 +137,3 @@ var superagent = require("superagent");

this.prepareRequest = function(req){
return req.auth(userName, password);
return req.auth(userName, password).set("User-Agent", "node-numbers");
};

@@ -140,0 +140,0 @@

@@ -33,3 +33,6 @@ var Promise = require("bluebird");

EmergencyNotification: require("./emergencyNotification"),
Aeuis: require("./aeuis")
Aeuis: require("./aeuis"),
Application: require('./application'),
Geocode: require('./geocode'),
TnOption: require('./tnOption')
};

@@ -42,2 +45,2 @@

}
}
}

@@ -81,3 +81,77 @@ var Client = require("./client");

SipPeer.prototype.listApplication = function(callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
this.client.makeRequest("get", url, function (err, results) {
if (err) {
callback(err);
}
else {
var apps = results.applicationSettings;
if (!Array.isArray(apps.httpMessagingV2AppId) && apps.httpMessagingV2AppId) {
apps.httpMessagingV2AppId = [apps.httpMessagingV2AppId]
}
callback(null, apps)
}
})
}
SipPeer.prototype.editApplication = function(appData, callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
const data = {applicationsSettings: appData}
this.client.makeRequest("put", url, data, function (err, results) {
if (err) {callback(err);}
else {
var apps = results.applicationSettings;
callback(null, apps)
}
});
}
SipPeer.prototype.removeApplication = function(callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
const data = {applicationsSettings: 'REMOVE'}
this.client.makeRequest("put", url, data, callback);
}
SipPeer.prototype.getSmsSettings = function(callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "features" + "/" + "sms");
this.client.makeRequest("get", url, function (err, results) {
if (err) {callback(err);}
else {
var settings = results.sipPeerSmsFeature;
if (settings.smppHosts && !Array.isArray(settings.smppHosts.smppHost)){
settings.smppHosts.smppHost = [settings.smppHosts.smppHost]
}
callback(null, settings);
}
});
}
SipPeer.prototype.deleteSmsSettings = function(callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "features" + "/" + "sms");
this.client.makeRequest("delete", url, callback);
}
SipPeer.prototype.createSmsSettings = function(settings, callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "features" + "/" + "sms");
settings = {sipPeerSmsFeature: settings}
this.client.makeRequest("post", url, settings, function (err, res) {
if (err) {
return callback(err);
}
callback(err, res.sipPeerSmsFeature)
});
}
SipPeer.prototype.editSmsSettings = function(settings, callback) {
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "features" + "/" + "sms");
settings = {sipPeerSmsFeature: settings}
this.client.makeRequest("put", url, settings, function (err, res) {
if (err) {
return callback(err);
}
callback(err, res.sipPeerSmsFeature)
});
}
module.exports = SipPeer;
{
"name": "@bandwidth/numbers",
"version": "1.3.0",
"version": "1.4.0",
"description": "NodeJs Client library for Bandwidth Numbers API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,3 +24,4 @@ # node-numbers

| 1.2.2 | Readme Typo for `RemoveImportedTnOrder` |
| 1.3.0 | Added Emergency Calling Notification endpoints |
| 1.3.0 | Added Emergency Calling Notification endpoints |
| 1.4.0 | Added TnOptions endpoints and functionality, along with SMS options on sip peers. |

@@ -148,3 +149,69 @@

## Applications
### Create Voice Application
```Javascript
var data = {
appName:"test app",
callInitiatedCallbackUrl: "http://example.com",
callInitiatedMethod: "POST",
callStatusCallbackUrl: "http://example.com",
callStatusMethod: "POST"
callbackCreds: {
userId: 'my-id',
password: 'my-password'
}
};
numbers.Application.createVoiceApplication(data, callback);
```
### Create Messaging Application
```Javascript
var data = {
appName:"test app",
msgCallbackUrl: "http://example.com",
callbackCreds: {
userId: 'my-id',
password: 'my-password'
}
};
numbers.Application.createMessagingApplication(data, callback);
```
### List All Applications
```Javascript
numbers.Application.list(callback);
```
### Get an Application
```Javascript
numbers.Application.get(id, callback);
```
### Update an Application
```Javascript
numbers.Application.get(id, (err, app) => {
app.appName = "new name";
app.update(app, callback);
});
```
### Delete an Application
```Javascript
numbers.Application.get(id, (err, app) => {
app.delete(callback)
});
```
### Get SipPeers Associated With and Application
```Javascript
numbers.Application.get(id, (err, app) => {
app.getSipPeers(callback);
});
```
## Available Numbers

@@ -643,2 +710,43 @@

### SipPeer link Application Methods
```Javascript
numbers.SipPeer.get(function(err,sipPeer){
// List application associated with this peer
sipPeer.listApplication(callback);
// Associate an application with this peer
var appId = "my-application-id";
sipPeer.editApplication({httpMessagingV2AppId: appId}, callback);
// Dissociate all applications with this peer
sipPeer.removeApplication(callback);
```
### SipPeer SMS settings
```Javascript
numbers.SipPeer.get(function(err,sipPeer){
// Get the sms settings associated with the peer
sipPeer.getSmsSettings(callback);
var desiredsettings = {
sipPeerSmsFeatureSettings: {
tollFree: true,
zone1: false,
zone2: true,
protocol: "HTTP"
}
};
//Change settings
sipPeer.editSmsSettings(desiredsettings, callback);
//Create settings
sipPeer.createSmsSettings(desiredsettings, callback);
//Delete
sipPeer.deleteSmsSettings(callback);
```
## Sites

@@ -806,3 +914,78 @@

```
## TN Options
### List TN Options
```js
const query = {
createdDateFrom : "2013-10-22T00:00:00.000Z",
orderDetails: true,
tn: 123456789
}
numbers.TnOption.list(client, query, (err, tnOptions) => {
if (err) {
console.error(err);
}
console.log(tnOptions);
})
```
### Find a specific TN Option Order
```js
const tnOptionOrderId = 'fakeOrderId';
numbers.TnOption.get(tnOptionOrderId, (err, tnOption) => {
if (err) {
console.error(err);
}
console.log(tnOptions);
})
```
### Add a PortOutPasscode
```js
const tnOptionsOrder = {
customerOrderId: 'myOrderId',
tnOptionGroups: [
{
portOutPasscode: 'mypass1',
telephoneNumbers: ['1234567890']
}
]
}
numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get
```
### Create Call Forward Number
```js
const tnOptionsOrder = {
customerOrderId: 'myOrderId',
tnOptionGroups: [
{
callForward: '2345678901',
telephoneNumbers: ['1234567890']
}
]
}
numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get
```
### Enable SMS
```js
const tnOptionsOrder = {
customerOrderId: 'myOrderId',
tnOptionGroups: [
{
sms: 'on',
telephoneNumbers: ['1234567890']
}
]
}
numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get
```
## Hosted Messaging

@@ -1097,2 +1280,23 @@

## Geocoding
### Make a geocode request
```Javascript
var data = data = {
addressLine1: "900 Main Campus Dr",
city: 'raleigh',
stateCode: 'nc',
zip: 27606
}
numbers.Geocode.request(data, function(error, address) {
if (error) {
return callback(error)
}
console.log(address.stateCode, address.houseNumber, address.streetName, address.streetSuffix, address.city)
//NC, 900, Main Campus, Dr, Raleigh
});
```
## Aeuis

@@ -1099,0 +1303,0 @@

@@ -196,2 +196,290 @@ var lib = require("../");

});
describe("#listApplication", function() {
it("should list application", function(done) {
var span = helper.nock().get("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings").reply(200, helper.xml.peerApplications, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.listApplication(function(err, results) {
if (err) {
done(err);
} else {
results.httpMessagingV2AppId[0].should.equal(100)
done();
}
});
});
});
describe("#editApplication", function() {
it("should edit the application", function(done) {
var appData = {httpMessagingV2AppId: 100}
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings", helper.buildXml({applicationsSettings: appData})).reply(200, helper.xml.peerApplications, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
var appData = {httpMessagingV2AppId: 100}
peer.editApplication(appData, function(err, results) {
if (err) {
done(err);
} else {
results.httpMessagingV2AppId.should.equal(100)
done();
}
});
});
it("should fail on an error", function(done) {
var appData = {httpMessagingV2AppId: 100}
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings", helper.buildXml({applicationsSettings: appData})).reply(400);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
var appData = {httpMessagingV2AppId: 100}
peer.editApplication(appData, function(err, results) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
describe("#removeApplication", function() {
it("should remove application", function(done) {
var appData = 'REMOVE';
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings", helper.buildXml({applicationsSettings: appData})).reply(200, helper.xml.peerApplications, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.removeApplication(done);
});
it("should fail on an error", function(done) {
var appData = 'REMOVE';
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings", helper.buildXml({applicationsSettings: appData})).reply(400);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.removeApplication(function(err) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
describe("#getSmsSettings", function() {
it("should get SMS settings", function(done) {
var span = helper.nock().get("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms").reply(200, helper.xml.peerSmsSettings, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.getSmsSettings(function(err, results) {
if (err) {
done(err);
} else {
results.sipPeerSmsFeatureSettings.tollFree.should.equal(true);
results.sipPeerSmsFeatureSettings.protocol.should.equal('SMPP');
results.smppHosts.smppHost.length.should.equal(1);
results.smppHosts.smppHost[0].hostId.should.equal(18);
done();
}
});
});
it("should fail on error status code", function(done) {
var span = helper.nock().get("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms").reply(400, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.getSmsSettings(function(err, results) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
describe("#deleteSmsSettings", function() {
it("should delete SMS settings", function(done) {
var span = helper.nock().delete("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms").reply(200);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.deleteSmsSettings(done);
});
it("should fail on error status code", function(done) {
var span = helper.nock().delete("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms").reply(400);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.deleteSmsSettings(function (err) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
describe("#editSmsSettings", function() {
it("should create SMS settings", function(done) {
var settingsData = {
sipPeerSmsFeatureSettings: {
tollFree: true,
shortCode: true,
A2pLongCode: 'DefaultOff',
zone1:true,
zone2:true,
zone3:true,
zone4:true,
zone5:true,
},
smppHosts: {
smppHost: [
{
priority:0,
connectionType: 'RECEIVER_ONLY',
hostId: 18
}
]
}
}
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms", helper.buildXml({sipPeerSmsFeature: settingsData})).reply(200, helper.xml.peerSmsSettings, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.editSmsSettings(settingsData, function(err, results) {
if (err) {
done(err);
} else {
results.sipPeerSmsFeatureSettings.zone5.should.equal(true);
done();
}
});
});
it("should fail for error status code", function(done) {
var settingsData = {
sipPeerSmsFeatureSettings: {
tollFree: true,
shortCode: true,
A2pLongCode: 'DefaultOff',
zone1:true,
zone2:true,
zone3:true,
zone4:true,
zone5:true,
},
smppHosts: {
smppHost: [
{
priority:0,
connectionType: 'RECEIVER_ONLY',
hostId: 18
}
]
}
}
var span = helper.nock().put("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms", helper.buildXml({sipPeerSmsFeature: settingsData})).reply(400);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.editSmsSettings(settingsData, function(err, results) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
describe("#createSmsSettings", function() {
it("should create SMS settings", function(done) {
var settingsData = {
sipPeerSmsFeatureSettings: {
tollFree: true,
shortCode: true,
A2pLongCode: 'DefaultOff',
zone1:true,
zone2:true,
zone3:true,
zone4:true,
zone5:true,
},
smppHosts: {
smppHost: [
{
priority:0,
connectionType: 'RECEIVER_ONLY',
hostId: 18
}
]
}
}
var span = helper.nock().post("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms", helper.buildXml({sipPeerSmsFeature: settingsData})).reply(200, helper.xml.peerSmsSettings, {"Content-Type": "application/xml"});
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.createSmsSettings(settingsData, function(err, results) {
if (err) {
done(err);
} else {
results.sipPeerSmsFeatureSettings.zone5.should.equal(true);
done();
}
});
});
it("should fail for error status code", function(done) {
var settingsData = {
sipPeerSmsFeatureSettings: {
tollFree: true,
shortCode: true,
A2pLongCode: 'DefaultOff',
zone1:true,
zone2:true,
zone3:true,
zone4:true,
zone5:true,
},
smppHosts: {
smppHost: [
{
priority:0,
connectionType: 'RECEIVER_ONLY',
hostId: 18
}
]
}
}
var span = helper.nock().post("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/features/sms", helper.buildXml({sipPeerSmsFeature: settingsData})).reply(400);
var peer = new SipPeer();
peer.id = 10;
peer.siteId = 1;
peer.client = helper.createClient();
peer.createSmsSettings(settingsData, function(err, results) {
if (err) {
done();
} else {
done(new Error('An error is expected'));
}
});
});
});
});
{
"peerSmsSettings": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeerSmsFeatureResponse><SipPeerSmsFeature><SipPeerSmsFeatureSettings><TollFree>true</TollFree><ShortCode>true</ShortCode><A2pLongCode>DefaultOff</A2pLongCode><A2pMessageClass>SomeMessageClass</A2pMessageClass><A2pCampaignId>SomeCampaignId</A2pCampaignId><Protocol>SMPP</Protocol><Zone1>true</Zone1><Zone2>true</Zone2><Zone3>true</Zone3><Zone4>true</Zone4><Zone5>true</Zone5></SipPeerSmsFeatureSettings><SmppHosts><SmppHost><HostName>54.10.88.146</HostName><HostId>18</HostId><Priority>0</Priority><ConnectionType>RECEIVER_ONLY</ConnectionType></SmppHost></SmppHosts></SipPeerSmsFeature></SipPeerSmsFeatureResponse>",
"tnOptions": "<TnOptionOrders><TotalCount>2</TotalCount><TnOptionOrderSummary><accountId>accountId</accountId><CountOfTNs>1</CountOfTNs><userId>userId</userId><lastModifiedDate>lastModifiedDate</lastModifiedDate><OrderDate>orderDate</OrderDate><OrderType>orderType</OrderType><OrderStatus>FAILED</OrderStatus><OrderId>orderId</OrderId></TnOptionOrderSummary><TnOptionOrderSummary><accountId>14</accountId><CountOfTNs>3</CountOfTNs><userId>userId</userId><lastModifiedDate>lastModifiedDate</lastModifiedDate><OrderDate>orderDate</OrderDate><OrderType>tn_option</OrderType><OrderStatus>COMPLETE</OrderStatus><OrderId>orderId2</OrderId></TnOptionOrderSummary></TnOptionOrders>",
"tnOption": "<TnOptionOrder><OrderCreateDate>createdDate</OrderCreateDate><AccountId>14</AccountId><CreatedByUser>user</CreatedByUser><OrderId>orderId</OrderId><LastModifiedDate>dateHere</LastModifiedDate><ProcessingStatus>FAILED</ProcessingStatus><TnOptionGroups><TnOptionGroup><NumberFormat>10digit</NumberFormat><RPIDFormat>10digit</RPIDFormat><RewriteUser>testUser1</RewriteUser><CallForward>6042661720</CallForward><CallingNameDisplay>on</CallingNameDisplay><Protected>true</Protected><Sms>on</Sms><FinalDestinationURI>sip:+12345678901@1.2.3.4:5060</FinalDestinationURI><TelephoneNumbers><TelephoneNumber>2018551020</TelephoneNumber></TelephoneNumbers></TnOptionGroup><TnOptionGroup><CallingNameDisplay>off</CallingNameDisplay><Protected>false</Protected><Sms>off</Sms><TelephoneNumbers><TelephoneNumber>2018551025</TelephoneNumber></TelephoneNumbers></TnOptionGroup></TnOptionGroups></TnOptionOrder>",
"geocode": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><GeocodeRequestResponse><GeocodedAddress><AddressLine1>1 Street Name</AddressLine1><HouseNumber>1</HouseNumber><StreetName>Street</StreetName><StreetSuffix>Name</StreetSuffix><City>City</City><StateCode>State</StateCode><Zip>ZipCode</Zip><PlusFour>1234</PlusFour><Country>US</Country></GeocodedAddress></GeocodeRequestResponse>",
"peerApplications": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ApplicationSettingsResponse><ApplicationSettings><HttpMessagingV2AppId>100</HttpMessagingV2AppId></ApplicationSettings></ApplicationSettingsResponse>",
"application": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ApplicationProvisioningResponse><Application><ApplicationId>1</ApplicationId><ServiceType>Messaging-V2</ServiceType><AppName>Test Application</AppName><MsgCallbackUrl>http://a.com</MsgCallbackUrl></Application></ApplicationProvisioningResponse>",
"voiceApplication": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ApplicationProvisioningResponse><Application><ApplicationId>2</ApplicationId><AppName>Test Application 2</AppName><ServiceType>Voice-V2</ServiceType><CallInitiatedCallbackUrl>http://b.com</CallInitiatedCallbackUrl></Application></ApplicationProvisioningResponse>",
"applications": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ApplicationProvisioningResponse><ApplicationList><Application><ApplicationId>1</ApplicationId><ServiceType>Messaging-V2</ServiceType><AppName>Test Application</AppName><MsgCallbackUrl>http://a.com</MsgCallbackUrl></Application><Application><ApplicationId>2</ApplicationId><AppName>Test Application 2</AppName><ServiceType>Voice-V2</ServiceType><CallInitiatedCallbackUrl>http://b.com</CallInitiatedCallbackUrl></Application></ApplicationList></ApplicationProvisioningResponse>",
"applicationSipPeers": "<AssociatedSipPeersResponse><AssociatedSipPeers><AssociatedSipPeer><SiteId>1</SiteId><SiteName>Site Name</SiteName><PeerId>2</PeerId><PeerName>Peer Name</PeerName></AssociatedSipPeer></AssociatedSipPeers></AssociatedSipPeersResponse>",
"sites": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SitesResponse><Sites><Site><Id>1</Id><Name>Test Site</Name><Description>A site description</Description></Site><Site><Id>2</Id><Name>Test Site 2</Name><Description>A site description</Description></Site></Sites></SitesResponse>",

@@ -3,0 +12,0 @@ "site": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SiteResponse><Site><Id>1</Id><Name>Test Site</Name><Description>A Site Description</Description><Address><HouseNumber>900</HouseNumber><StreetName>Main Campus Drive</StreetName><City>Raleigh</City><StateCode>NC</StateCode><Zip>27615</Zip><Country>United States</Country><AddressType>Service</AddressType></Address></Site></SiteResponse>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc