Skip to content

Commit 1d8c616

Browse files
committed
change aplpication to singular in sippeer and specify appId in readme
1 parent 0279e71 commit 1d8c616

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,15 @@ numbers.SipPeer.get(function(err,sipPeer){
708708

709709
```Javascript
710710
numbers.SipPeer.get(function(err,sipPeer){
711-
// List applications associated with this peer
712-
sipPeer.listApplications(callback);
711+
// List application associated with this peer
712+
sipPeer.listApplication(callback);
713713

714714
// Associate an application with this peer
715-
sipPeer.editApplications({httpMessagingV2AppId: [appId]}, callback);
715+
var appId = "my-application-id";
716+
sipPeer.editApplication({httpMessagingV2AppId: appId}, callback);
716717

717718
// Dissociate all applications with this peer
718-
sipPeer.removeApplications(callback);
719+
sipPeer.removeApplication(callback);
719720
```
720721
721722

lib/sipPeer.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ SipPeer.prototype.moveTns = function(numbers, callback){
7878
this.client.makeRequest("post", url, {sipPeerTelephoneNumbers: {fullNumber: numbers}}, callback);
7979
};
8080

81-
SipPeer.prototype.listApplications = function(callback) {
81+
SipPeer.prototype.listApplication = function(callback) {
8282
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
8383
this.client.makeRequest("get", url, function (err, results) {
8484
if (err) {
@@ -94,22 +94,19 @@ SipPeer.prototype.listApplications = function(callback) {
9494
})
9595
}
9696

97-
SipPeer.prototype.editApplications = function(appData, callback) {
97+
SipPeer.prototype.editApplication = function(appData, callback) {
9898
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
9999
const data = {applicationsSettings: appData}
100100
this.client.makeRequest("put", url, data, function (err, results) {
101101
if (err) {callback(error);}
102102
else {
103103
var apps = results.applicationSettings;
104-
if (!Array.isArray(apps.httpMessagingV2AppId)) {
105-
apps.httpMessagingV2AppId = [apps.httpMessagingV2AppId]
106-
}
107104
callback(null, apps)
108105
}
109106
});
110107
}
111108

112-
SipPeer.prototype.removeApplications = function(callback) {
109+
SipPeer.prototype.removeApplication = function(callback) {
113110
var url = this.client.concatAccountPath(SITE_PATH + "/" + this.siteId + "/" + SIP_PEER_PATH + "/" + this.id + "/" + "products" + "/" + "messaging" + "/" + "applicationSettings");
114111
const data = {applicationsSettings: 'REMOVE'}
115112
this.client.makeRequest("put", url, data, callback);

test/sipPeer.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ describe("SipPeer", function(){
193193
peer.moveTns(data, done);
194194
});
195195
});
196-
describe("#listApplications", function() {
197-
it("should list applications", function(done) {
196+
describe("#listApplication", function() {
197+
it("should list application", function(done) {
198198
var span = helper.nock().get("/accounts/FakeAccountId/sites/1/sippeers/10/products/messaging/applicationSettings").reply(200, helper.xml.peerApplications, {"Content-Type": "application/xml"});
199199
var peer = new SipPeer();
200200
peer.id = 10;
201201
peer.siteId = 1;
202202
peer.client = helper.createClient();
203-
peer.listApplications(function(err, results) {
203+
peer.listApplication(function(err, results) {
204204
if (err) {
205205
done(err);
206206
} else {
@@ -210,34 +210,34 @@ describe("SipPeer", function(){
210210
});
211211
});
212212
});
213-
describe("#editApplications", function() {
214-
it("should edit applications", function(done) {
213+
describe("#editApplication", function() {
214+
it("should edit the application", function(done) {
215215
var appData = {httpMessagingV2AppId: 100}
216216
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"});
217217
var peer = new SipPeer();
218218
peer.id = 10;
219219
peer.siteId = 1;
220220
peer.client = helper.createClient();
221-
var appData = [{httpMessagingV2AppId: 100}]
222-
peer.editApplications(appData, function(err, results) {
221+
var appData = {httpMessagingV2AppId: 100}
222+
peer.editApplication(appData, function(err, results) {
223223
if (err) {
224224
done(err);
225225
} else {
226-
results.httpMessagingV2AppId[0].should.equal(100)
226+
results.httpMessagingV2AppId.should.equal(100)
227227
done();
228228
}
229229
});
230230
});
231231
});
232-
describe("#removeApplications", function() {
233-
it("should remove applications", function(done) {
232+
describe("#removeApplication", function() {
233+
it("should remove application", function(done) {
234234
var appData = 'REMOVE';
235235
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"});
236236
var peer = new SipPeer();
237237
peer.id = 10;
238238
peer.siteId = 1;
239239
peer.client = helper.createClient();
240-
peer.removeApplications(done);
240+
peer.removeApplication(done);
241241
});
242242
});
243243

0 commit comments

Comments
 (0)