Skip to content

Commit ea0cea4

Browse files
committed
Better readme and minor changes in API interface
2 parents d3340d1 + 2e94702 commit ea0cea4

File tree

6 files changed

+67
-16
lines changed

6 files changed

+67
-16
lines changed

.codeclimate.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
engines:
22
eslint:
33
enabled: true
4-
4+
channel: "eslint-2"
5+
config:
6+
config: .eslintrc.json
57
ratings:
68
paths:
7-
- "lib/**"
8-
- "spec/**"
9-
10-
#exclude_paths:
9+
- bin/**/*.js
10+
- lib/**/*.js
11+
exclude_paths:
12+
- "node_modules/**"

.eslintrc.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@
120120
"space-in-parens": ["error", "never"],
121121
"space-infix-ops": "error",
122122
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
123-
"unicode-bom": ["error", "never"]
123+
"unicode-bom": ["error", "never"],
124+
"curly": "error",
125+
"complexity": "error",
126+
"block-spacing": "error"
127+
},
128+
"globals": {
129+
"AnalysisView": true,
130+
"PollingView": true,
131+
"Prism": true,
132+
"Spinner": true,
133+
"Timer": true,
134+
"moment": true
124135
}
125136
}

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
# samwise
22

3-
[![Coverage Status](https://coveralls.io/repos/github/NuAxis/samwise/badge.svg)](https://coveralls.io/github/NuAxis/samwise)
3+
[![Build Status](https://travis-ci.org/NuAxis/samwise.svg?branch=develop)](https://travis-ci.org/NuAxis/samwise)
44
[![Code Climate](https://codeclimate.com/github/NuAxis/samwise/badges/gpa.svg)](https://codeclimate.com/github/NuAxis/samwise)
55
[![Test Coverage](https://codeclimate.com/github/NuAxis/samwise/badges/coverage.svg)](https://codeclimate.com/github/NuAxis/samwise/coverage)
6-
[![Issue Count](https://codeclimate.com/github/NuAxis/samwise/badges/issue_count.svg)](https://codeclimate.com/github/NuAxis/samwise)
76

87
A simple SAM API wrapper inspired by https://github.com/18F/samwise
98

10-
```npm install samwise```
9+
```npm install samwisejs```
10+
11+
## Interfaces
12+
```javascript
13+
var Samwise = require('samwisejs');
14+
15+
Samwise.Api.searchEntities(API_KEY, TERMS, function(error, entities) {});
16+
Samwise.Api.getRegistration(API_KEY, DUNS, function(error, registration) {});
17+
Samwise.Api.getGovBusinessPointOfContact(API_KEY, DUNS, function(error, contact) {});
18+
```
19+
20+
## Example
21+
22+
```javascript
23+
var Samwise = require('samwisejs');
24+
var DUNS = '1234567'; // 7,8,9 and 13 digit duns with/without dashes are accepted
25+
var DG_API_KEY = 'DEMO_KEY'; // get at https://api.data.gov/signup/
26+
var searchTerms = ''; // http://gsa.github.io/sam_api/sam/search.html
27+
28+
var printResult = function(error, entities) {
29+
if(!error && entities.length > 0) {
30+
for(var i = 0; i < entities.length; i++) {
31+
console.log(entities[i].legalBusinessName);
32+
}
33+
}
34+
}
35+
```
36+
37+
38+
## Build
39+
40+
``` gulp ```
41+
42+
OR
43+
44+
```npm test```
45+
46+
## Browserify
47+
48+
```npm run browserify```

lib/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var Api = {
1717
return this.pathV1 + '?qterms=' + qterms + '&api_key=' + apiKey;
1818
},
1919

20-
getRegistrations: function(apiKey, qterms, callback) {
20+
searchEntities: function(apiKey, qterms, callback) {
2121
/* istanbul ignore next */
2222
callback = callback || function() {};
2323
if (!apiKey || !qterms) {

spec/samwise/api_spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ describe('Duns', function() {
2424
});
2525
});
2626

27-
describe('#getRegistrations', function() {
27+
describe('#searchEntities', function() {
2828
it('should throw error if api key is not passed', function() {
2929
expect(function() {
30-
Samwise.Api.getRegistrations();
30+
Samwise.Api.searchEntities();
3131
}).toThrowError(Samwise.Errors.API_KEY_OR_QTERMS_MISSING);
3232
});
3333

3434
it('should return results array if correct params passed', function() {
3535
nock(Samwise.Api.baseUrl)
3636
.get(Samwise.Api.getSamV1Path(API_KEY, GOOD_QTERMS))
37-
.replyWithFile(200, __dirname + '/replies/registrations.json');
37+
.replyWithFile(200, __dirname + '/replies/entities.json');
3838

39-
Samwise.Api.getRegistrations(API_KEY, GOOD_QTERMS, function(error, registrations) {
39+
Samwise.Api.searchEntities(API_KEY, GOOD_QTERMS, function(error, entities) {
4040
expect(error).toBeNull();
41-
expect(registrations).not.toBeNull();
42-
expect(registrations.length).toBe(10);
41+
expect(entities).not.toBeNull();
42+
expect(entities.length).toBe(10);
4343
});
4444
});
4545
});

0 commit comments

Comments
 (0)