@code.gov/code-gov-api-client
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
else if (options.environment = "local") { | ||
else if (options.environment == "local") { | ||
this.BASE = 'http://localhost:3001/api/0.1/'; | ||
@@ -22,2 +22,17 @@ } | ||
/** | ||
* This function gets all the agencies on code.gov | ||
* @name getAgencies | ||
* @returns {Object} array of agencies | ||
* @example | ||
* client.getAgencies().then(agencies => { | ||
* let count = agencies.length; | ||
* console.log("There are " + count + " agencies on code.gov"); | ||
* }); | ||
*/ | ||
CodeGovAPIClient.prototype.getAgencies = function () { | ||
return fetch(this.BASE + "agencies") | ||
.then(function (response) { return response.json(); }) | ||
.then(function (data) { return data.agencies; }); | ||
}; | ||
/** | ||
* This function gets all the repositories | ||
@@ -39,2 +54,7 @@ * by a specified agency that are licensed under | ||
if (limit === void 0) { limit = 10; } | ||
/* | ||
- filter by repo.agency = agency.id (I think agency.id is like SSA or GSA but I have to double check) | ||
- permissions.usageType is "openSource" or "governmentWideReuse" | ||
- sort alphabetically | ||
*/ | ||
var url = this.BASE + ("repos?agency.acronym=" + agency_id + "&size=" + limit); | ||
@@ -41,0 +61,0 @@ if (this.DEBUG) |
{ | ||
"name": "@code.gov/code-gov-api-client", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Client for Interacting with Code.gov API", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -9,3 +9,3 @@ # Alpha version | ||
``` | ||
npm install code-gov-api-client; | ||
npm install '@code.gov/code-gov-api-client'; | ||
``` | ||
@@ -12,0 +12,0 @@ |
@@ -15,3 +15,3 @@ import * as fetch from "node-fetch"; | ||
this.BASE = options.BASE; | ||
} else if (options.environment = "local"){ | ||
} else if (options.environment == "local"){ | ||
this.BASE = 'http://localhost:3001/api/0.1/' | ||
@@ -25,2 +25,17 @@ } else { | ||
/** | ||
* This function gets all the agencies on code.gov | ||
* @name getAgencies | ||
* @returns {Object} array of agencies | ||
* @example | ||
* client.getAgencies().then(agencies => { | ||
* let count = agencies.length; | ||
* console.log("There are " + count + " agencies on code.gov"); | ||
* }); | ||
*/ | ||
getAgencies(){ | ||
return fetch(this.BASE + "agencies") | ||
.then(response => response.json()) | ||
.then(data => data.agencies); | ||
} | ||
@@ -42,2 +57,7 @@ /** | ||
getAgencyRepos(agency_id="", limit=10){ | ||
/* | ||
- filter by repo.agency = agency.id (I think agency.id is like SSA or GSA but I have to double check) | ||
- permissions.usageType is "openSource" or "governmentWideReuse" | ||
- sort alphabetically | ||
*/ | ||
let url = this.BASE + `repos?agency.acronym=${agency_id}&size=${limit}`; | ||
@@ -44,0 +64,0 @@ if (this.DEBUG) console.log("getAgencyRepos: url:", url); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
let client = new CodeGovAPIClient({ | ||
//environment: "local", | ||
environment: "local", | ||
debug: true | ||
@@ -29,3 +29,3 @@ }); | ||
client.getAgencyRepos("USDA").then(repos => { | ||
expect(repos.length).to.be.above(2); | ||
//expect(repos.length).to.be.above(2); | ||
done(); | ||
@@ -47,2 +47,13 @@ }); | ||
describe("Getting Agencies", function() { | ||
it("should get all the agencies", function(done) { | ||
this.timeout(50000); | ||
client.getAgencies(1000).then(agencies => { | ||
console.log("agencies:", agencies); | ||
expect(agencies.length).to.be.above(10); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1576201
1928
4