Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added start option for getTicker method #6

Merged
merged 3 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Get ticker information
**Parameters**

- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Options for the request:
- `options.start` **Int?** Return results from rank start and above
- `options.limit` **Int?** Only returns the top limit results
- `options.convert` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return price, 24h volume, and market cap in terms of another currency
- `options.currency` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return only specific currency
Expand All @@ -99,6 +100,7 @@ const client = new CoinMarketCap()
client.getTicker({limit: 3}).then(console.log).catch(console.error)
client.getTicker({limit: 1, currency: 'bitcoin'}).then(console.log).catch(console.error)
client.getTicker({convert: 'EUR'}).then(console.log).catch(console.error)
client.getTicker({start: 0, limit: 5}).then(console.log).catch(console.error)
```

### getGlobal
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class CoinMarketCap {
* Get ticker information
*
* @param {Object=} options Options for the request:
* @param {Int=} options.limit Only returns the top limit results
* @param {Int=} options.start Return results from rank start + 1 and above
* @param {Int=} options.limit Only returns limit number of results
* @param {String=} options.convert Return price, 24h volume, and market cap in terms of another currency
* @param {String=} options.currency Return only specific currency
*
Expand All @@ -27,12 +28,13 @@ class CoinMarketCap {
* client.getTicker({limit: 3}).then(console.log).catch(console.error)
* client.getTicker({limit: 1, currency: 'bitcoin'}).then(console.log).catch(console.error)
* client.getTicker({convert: 'EUR'}).then(console.log).catch(console.error)
* client.getTicker({start: 0, limit: 5}).then(console.log).catch(console.error)
*/
getTicker ({ limit, convert, currency }) {
getTicker ({ start, limit, convert, currency }) {
return createRequest({
url: `${this.url}/ticker${currency ? `/${currency}`.toLowerCase() : ''}`,
headers: this.headers,
query: { convert, limit }
query: { start, convert, limit }
})
}

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"devDependencies": {
"husky": "^0.14.3",
"jest": "^22.0.0",
"prettier-standard": "^8.0.0"
"jest": "^22.0.0",
"prettier-standard": "^7.0.1"
},
"dependencies": {
Expand Down