Skip to content

Commit 333ccbc

Browse files
authored
DX-2428 Closes #46 401 with CoveredRateCenter (#47)
* Closes #46 * update coveredratecenter model and add test * spacing * remove console.logs and update test * config * base url * add in query params * send it to pipedream * try to disable nock * try to use lib * require nock * try to reset url * log request * try to override username and password * is it getting environment vars?? * remove test env * change test script * change env * actually load in secrets * set the right this time * apsword * enable net connect * change test cmd * remove unneccesary line
1 parent 9755cc3 commit 333ccbc

File tree

5 files changed

+67
-6
lines changed

5 files changed

+67
-6
lines changed

.github/workflows/validate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ jobs:
2020
run: npm run build --if-present
2121
- name: NPM Test
2222
run: npm run test --if-present
23+
env:
24+
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
25+
BW_USERNAME: ${{ secrets.BW_USERNAME }}
26+
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}

lib/coveredRateCenter.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,39 @@ var COVERED_RATE_CENTER_PATH = "coveredRateCenters";
33

44
module.exports = {
55
list: function(client, query, callback){
6-
if(arguments.length === 2){
7-
callback = query;
8-
query = client;
9-
client = new Client();
6+
if (arguments.length == 2) {
7+
let args = Array.from(arguments);
8+
args.forEach(arg => {
9+
if (arg instanceof Client) {
10+
client = arg;
11+
} else if (typeof arg == 'object') {
12+
if (!(client instanceof Client)) {
13+
client = null;
14+
}
15+
query = arg;
16+
} else if (typeof arg == 'function') {
17+
if (!(client instanceof Client)) {
18+
client = null;
19+
}
20+
callback = arg;
21+
}
22+
});
23+
if (client == null) {
24+
client = new Client();
25+
}
26+
if (query == null) {
27+
query = {
28+
"page": 1,
29+
"size": 500
30+
}
31+
}
32+
if (callback == null) {
33+
console.log("Please provide a callback function.")
34+
process.exit(1);
35+
}
1036
}
37+
query.page = query.page || 1;
38+
query.size = query.size || 500;
1139
client.makeRequest("get", COVERED_RATE_CENTER_PATH, query, function(err, res){
1240
if(err){
1341
return callback(err);

package-lock.json

Lines changed: 1 addition & 1 deletion
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.7.1",
3+
"version": "1.7.2",
44
"description": "NodeJs Client library for Bandwidth Numbers API",
55
"main": "index.js",
66
"scripts": {

test/coveredRateCenter.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var lib = require("../");
2+
var nock = require("nock");
3+
4+
describe("coveredRateCenter", function(){
5+
before(function(){
6+
lib.Client.globalOptions.accountId = process.env.BW_ACCOUNT_ID;
7+
lib.Client.globalOptions.userName = process.env.BW_USERNAME;
8+
lib.Client.globalOptions.password = process.env.BW_PASSWORD;
9+
});
10+
after(function(){
11+
lib.Client.globalOptions.apiEndPoint = "https://dashboard.bandwidth.com/api";
12+
nock.cleanAll();
13+
nock.enableNetConnect();
14+
});
15+
describe("#list", function(){
16+
it("should return list of coveredRateCenters", function(done){
17+
lib.CoveredRateCenter.list({zip: 27606, page: 1, size: 500}, function(err, list){
18+
if(err){
19+
return done(err);
20+
}
21+
list.length.should.equal(1);
22+
list[0].name.should.equal("RALEIGH");
23+
list[0].abbreviation.should.equal("RALEIGH");
24+
done();
25+
});
26+
});
27+
});
28+
});
29+

0 commit comments

Comments
 (0)