dispatch-node-sdk
Advanced tools
Comparing version 0.0.36 to 0.0.37
@@ -17,2 +17,3 @@ import _ from 'underscore'; | ||
import Configuration from './configuration'; | ||
import surveyMethods from './entities/survey'; | ||
import userMethods from './entities/user'; | ||
@@ -50,2 +51,3 @@ | ||
organizations: new Collection(this, endpoints.ORGANIZATIONS), | ||
survey: surveyMethods(this), | ||
user: userMethods(this), | ||
@@ -52,0 +54,0 @@ users: new Collection(this, endpoints.USERS), |
@@ -13,3 +13,4 @@ export const ACCOUNTS = '/v1/accounts'; | ||
export const ORGANIZATIONS = '/v1/organizations'; | ||
export const PUBLIC_SURVEY_RESPONSES = '/v1/public/survey_responses'; | ||
export const SURVEY_RESPONSES = '/v1/survey_responses'; | ||
export const USERS = '/v1/users'; |
@@ -101,3 +101,17 @@ import * as endpoints from '../endpoints'; | ||
}, | ||
getSurveys: (query = {}) => { | ||
const DEFAULT_QUERY = { | ||
job_id_eq: id, | ||
}; | ||
if (query.filter) { | ||
query.filter = Object.assign({}, query.filter, DEFAULT_QUERY); | ||
} else { | ||
query.filter = DEFAULT_QUERY; | ||
} | ||
return client.getCollection(endpoints.SURVEY_RESPONSES, query); | ||
}, | ||
}); | ||
} |
@@ -180,2 +180,27 @@ import expect from 'expect'; | ||
}); | ||
describe('getSurveys', () => { | ||
it('should call endpoint with correct default query string', () => { | ||
const client = new Dispatch(testClientID, testClientSecret); | ||
const scope = nock('https://api.dispatch.me') | ||
.get(`${endpoints.SURVEY_RESPONSES}?filter[job_id_eq]=123`) | ||
.reply(200); | ||
client.setBearerToken(testBearerToken, testRefreshToken); | ||
client.entities.job(123).getSurveys(); | ||
expect(scope.isDone()).toEqual(true); | ||
}); | ||
it('should allow a specified query string', () => { | ||
const client = new Dispatch(testClientID, testClientSecret); | ||
const query = { filter: { is_submitted_eq: false } }; | ||
const scope = nock('https://api.dispatch.me') | ||
.get(`${endpoints.SURVEY_RESPONSES}?filter[is_submitted_eq]=false&filter[job_id_eq]=123`) | ||
.reply(200); | ||
client.setBearerToken(testBearerToken, testRefreshToken); | ||
client.entities.job(123).getSurveys(query); | ||
expect(scope.isDone()).toEqual(true); | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "dispatch-node-sdk", | ||
"version": "0.0.36", | ||
"version": "0.0.37", | ||
"description": "High- and low-level libraries for interacting with the Dispatch API", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
@@ -87,2 +87,34 @@ Dispatch JavaScript SDK | ||
You can also get meta data (such as pagination, etc.) using `getCollectionWithMeta`: | ||
```javascript | ||
client.getCollectionWithMeta('/v1/jobs', { | ||
filter: { | ||
status_eq: 'unscheduled', | ||
} | ||
}).then(response => { | ||
... | ||
}) | ||
``` | ||
where response has the following structure: | ||
```javascript | ||
response: { | ||
data: [...], | ||
meta: {...}, | ||
} | ||
``` | ||
if there are more then one sources of data returned from the API that are not meta: | ||
```javascript | ||
response: { | ||
data: { | ||
source1: [...], | ||
source2: [...], | ||
... | ||
}, | ||
meta: {...}, | ||
} | ||
``` | ||
#### Creating a Model | ||
@@ -89,0 +121,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
172875
59
4449
248
1