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

Commit f0b061b

Browse files
committed
added status
1 parent 6f8878d commit f0b061b

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
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.2.6",
3+
"version": "0.2.7",
44
"description": "Client for Interacting with Code.gov API",
55
"main": "dist/bundle.js",
66
"scripts": {

src/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,37 @@ class CodeGovAPIClient {
9898
return this.repos(filters)
9999
}
100100

101+
getCompliance() {
102+
return this.getStatus().then(dirty => {
103+
const { statuses } = dirty;
104+
const data = Object.values(statuses)
105+
.filter(value => value.requirements)
106+
.map(value => {
107+
const acronym = value.metadata.agency.acronym;
108+
const name = value.metadata.agency.name;
109+
const reqs = value.requirements;
110+
return {
111+
name,
112+
acronym,
113+
requirements: {
114+
overall: reqs.overallCompliance,
115+
sub: {
116+
agencyWidePolicy: reqs.agencyWidePolicy,
117+
openSourceRequirement: reqs.openSourceRequirement,
118+
inventoryRequirement: reqs.inventoryRequirement,
119+
schemaFormat: reqs.schemaFormat
120+
}
121+
}
122+
}
123+
})
124+
.sort((a, b) => {
125+
const pattern = /Department of( the)?/
126+
return a.name.replace(pattern, "").toLowerCase() > b.name.replace(pattern, "").toLowerCase() ? 1 : -1
127+
});
128+
return data
129+
})
130+
}
131+
101132
/**
102133
* This function gets a repository by its id
103134
* It is used on the project details page of code.gov.
@@ -232,6 +263,10 @@ class CodeGovAPIClient {
232263
return Promise.resolve(null)
233264
}
234265

266+
getStatus() {
267+
return this.getJSON(`${this.base}status.json`)
268+
}
269+
235270

236271
tasks(params) {
237272
let { agencies, from, languages, skillLevels, size, timeRequired } = params || {}

0 commit comments

Comments
 (0)