Skip to content

Commit 0733f49

Browse files
authored
Merge pull request #31 from Bandwidth/DX-1535
added get products
2 parents 60409d6 + 431794b commit 0733f49

File tree

6 files changed

+63
-15
lines changed

6 files changed

+63
-15
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This SDK stable for node versions 7 and above
2424
| 1.3.0 | Added Emergency Calling Notification endpoints |
2525
| 1.4.0 | Added TnOptions endpoints and functionality, along with SMS options on sip peers. |
2626
| 1.6.0 | Added create origination settings for sip peers |
27+
| 1.7.0 | Added get products to account |
2728

2829

2930
## Install
@@ -1385,3 +1386,9 @@ var voiceHttpSettings = {
13851386
}
13861387
await sipPeer.createOriginationSettingsAsync({voiceProtocol: "HTTP", httpSettings: voiceHttpSettings})
13871388
```
1389+
1390+
## Get Account Products
1391+
1392+
```js
1393+
console.log(await numbers.Account.getProductsAsync());
1394+
```

lib/account.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,18 @@ module.exports = {
1212
}
1313
callback(null, res.account);
1414
});
15+
},
16+
17+
getProducts: function(client, callback) {
18+
if(arguments.length === 1){
19+
callback = client;
20+
client = new Client();
21+
}
22+
client.makeRequest("get", client.concatAccountPath("products"), function(err,res) {
23+
if(err){
24+
return callback(err);
25+
}
26+
callback(null, res.products);
27+
});
1528
}
16-
}
29+
}

package-lock.json

Lines changed: 26 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bandwidth/numbers",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"description": "NodeJs Client library for Bandwidth Numbers API",
55
"main": "index.js",
66
"scripts": {

test/account.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,17 @@ describe("Account", function(){
2424
});
2525
});
2626
});
27+
describe("#getProducts", function(){
28+
it("should get account product info", function(done){
29+
helper.nock().get("/accounts/FakeAccountId/products").reply(200, helper.xml.accountProducts, {"Content-Type": "application/xml"});
30+
Account.getProducts(helper.createClient(), function(err, accountProducts){
31+
if(err) {
32+
return done(err);
33+
}
34+
accountProducts.product[0].name.should.eql("Termination");
35+
accountProducts.product[1].name.should.eql("VirtualInventory");
36+
done();
37+
});
38+
});
39+
});
2740
});

test/xml.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@
6666
"removeImportedTnOrderResponse": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><RemoveImportedTnOrdersResponse><RemoveImportedTnOrder><CustomerOrderId>ICPA123ABC</CustomerOrderId><OrderCreateDate>2020-02-11T18:18:48.794Z</OrderCreateDate><AccountId>9900778</AccountId><CreatedByUser>dtolb-API</CreatedByUser><OrderId>7527b3fc-3f72-4d0a-acae-ccc7e77857ed</OrderId><LastModifiedDate>2020-02-11T18:18:48.794Z</LastModifiedDate><TelephoneNumbers><TelephoneNumber>9199918388</TelephoneNumber><TelephoneNumber>4158714245</TelephoneNumber><TelephoneNumber>4352154439</TelephoneNumber><TelephoneNumber>4352154466</TelephoneNumber></TelephoneNumbers><ProcessingStatus>RECEIVED</ProcessingStatus><Errors/></RemoveImportedTnOrder></RemoveImportedTnOrdersResponse>",
6767
"csrOrder": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CsrResponse><LastModifiedBy>user</LastModifiedBy><OrderCreateDate>2020-02-25T15:39:22.079Z</OrderCreateDate><AccountId>9999999</AccountId><OrderId>20ba7d26-7fa0-4716-ab45-6c8e07d37862</OrderId><LastModifiedDate>2020-02-25T15:39:41.166Z</LastModifiedDate><Status>COMPLETE</Status><CsrData><CustomerName>House of Mouse</CustomerName><ServiceAddress><UnparsedAddress>1234 Main ST Durham NC 27707</UnparsedAddress><HouseNumber>1234</HouseNumber><StreetName>Main</StreetName><StreetSuffix>ST</StreetSuffix><City>Durham</City><State>NC</State><Zip>27707</Zip></ServiceAddress><WorkingTelephoneNumber>9198675309</WorkingTelephoneNumber><WorkingTelephoneNumbersOnAccount><TelephoneNumber>9198675309</TelephoneNumber></WorkingTelephoneNumbersOnAccount></CsrData></CsrResponse>",
6868
"csrResponse": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><CsrResponse><OrderId>218a295f-4f8a-4d1a-ba55-3e0aac6207cb</OrderId><Status>RECEIVED</Status></CsrResponse>",
69-
"originationSettings": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeerOriginationSettingsResponse> <SipPeerOriginationSettings> <VoiceProtocol>HTTP</VoiceProtocol> <HttpSettings> <HttpVoiceV2AppId>{{voice-applicationId}}</HttpVoiceV2AppId> </HttpSettings> </SipPeerOriginationSettings></SipPeerOriginationSettingsResponse>"
70-
}
69+
"originationSettings": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeerOriginationSettingsResponse> <SipPeerOriginationSettings> <VoiceProtocol>HTTP</VoiceProtocol> <HttpSettings> <HttpVoiceV2AppId>{{voice-applicationId}}</HttpVoiceV2AppId> </HttpSettings> </SipPeerOriginationSettings></SipPeerOriginationSettingsResponse>",
70+
"accountProducts": "<?xml version=\"1.0\"?><AccountProductsResponse> <Products> <Product><Name>Termination</Name><Features> <Feature>TermHttpVoice</Feature></Features> </Product> <Product><Name>VirtualInventory</Name> </Product></Products></AccountProductsResponse>"}

0 commit comments

Comments
 (0)