Skip to content

Commit

Permalink
add getSample function
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Nov 23, 2016
1 parent fe6a6d5 commit 35ac655
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/api/samples.md
@@ -1,6 +1,7 @@
# Samples API

- [bulkUpsertSamples](#bulkupsertsamples)
- [getSample](#getsample)


## bulkUpsertSamples
Expand All @@ -13,3 +14,15 @@ Insert or update an array of Samples asynchronously.
| arr | `Array` | The array of Samples to upsert. |

Returns a Bluebird `Promise` which resolves to the status OK.


## getSample
`getSample(name)` => `Promise`

Retrieve the specified Sample.

| Param | Type | Description |
| --- | --- | --- |
| name | `String` | The name of the Sample to retrieve. |

Returns a Bluebird `Promise` which resolves to the specified Sample.
11 changes: 11 additions & 0 deletions index.js
Expand Up @@ -179,6 +179,17 @@ class RefocusClient {
arr);
} // bulkUpsertSamples

/**
* Retrieve the specified sample.
*
* @param {String} name - The name of the sample to retrieve.
* @returns {Promise} a Bluebird Promise which resolves to the specified
* sample.
*/
getSample(name) {
return req.get(this.token, `${this.url}/${this.version}/samples/${name}`);
} // getSample

// --------------------------------------------------------------------------
// Functions for working with Perspectives...
// --------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions test/samples.js
Expand Up @@ -25,4 +25,22 @@ describe('samples', () => {
done();
});
}); // bulkUpsertSamples

it('getSample', (done) => {
rc.getSample('a.b.c|def')
.then((res) => done('Uh oh'))
.catch((err) => {
const opts = err.options;
expect(opts.headers).to.have.property('Authorization', 'abcdefg');
expect(opts.json).to.be.true;
expect(opts).to.have.property('method', 'GET');
expect(opts.resolveWithFullResponse).to.be.false;
expect(opts.simple).to.be.false;
expect(opts).to.have.property('uri', 'test/v1/samples/a.b.c|def');
expect(opts.transform).to.be.undefined;
expect(opts.transform2xxOnly).to.be.false;
done();
});
}); // getSubject

}); // samples

0 comments on commit 35ac655

Please sign in to comment.