Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit a0eb889

Browse files
committed
updated api client
1 parent d4d0068 commit a0eb889

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

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": "@code.gov/api-client",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Client for Interacting with Code.gov API",
55
"main": "dist/bundle.js",
66
"scripts": {

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CodeGovAPIClient {
3030
this._base = options.base || 'https://api.code.gov/'
3131
this.remember = options.remember || false
3232
this.debug = options.debug || false
33-
this.tasksUrl = options.tasksUrl || 'https://raw.githubusercontent.com/GSA/code-gov-data/master/help-wanted.json'
33+
this.tasksUrl = options.tasksUrl || 'https://api.code.gov/open-tasks'
3434
this.cache = {}
3535
this.count = 0
3636
this.max = 1000 // the maximum number of requests over the lifetime of this api client
@@ -295,7 +295,10 @@ class CodeGovAPIClient {
295295
from = this.from
296296
}
297297

298-
return this.getJSON(this.tasksUrl)
298+
let url = this.tasksUrl + `?size=${size}`
299+
if (this.api_key) url += `&api_key=${this.api_key}`
300+
301+
return this.getJSON(url)
299302
.then(data => {
300303
const result = {
301304
tasks: []

test/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,23 @@ describe('Getting Information', function() {
107107
});
108108
});
109109

110+
describe("Getting Tasks", function() {
111+
this.timeout(3000);
112+
it("should get 10 open tasks by default", function(done) {
113+
client.tasks().then(data => {
114+
console.log("data:", data);
115+
expect(data.tasks.length).to.equal(10);
116+
done();
117+
});
118+
});
119+
120+
it("should get all open tasks", function(done) {
121+
client.tasks({ size: 10000 }).then(data => {
122+
expect(data.tasks.length).to.be.above(10);
123+
done();
124+
});
125+
});
126+
127+
});
128+
110129
});

0 commit comments

Comments
 (0)