Skip to content

Commit

Permalink
Merge pull request #30 from ezewer/status-messages
Browse files Browse the repository at this point in the history
Add Status messages endpoint
  • Loading branch information
prdn authored Jul 18, 2019
2 parents 22355b9 + 2cddc8a commit 6e20b2a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
15 changes: 15 additions & 0 deletions doc/rest2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Communicates with v2 of the Bitfinex HTTP API
* [RESTv2](#RESTv2)
* [new RESTv2(opts)](#new_RESTv2_new)
* [.status(cb)](#RESTv2+status) ⇒ <code>Promise</code>
* [.statusMessages(type, keys, cb)](#RESTv2+statusMessages) ⇒ <code>Promise</code>
* [.ticker(symbol, cb)](#RESTv2+ticker) ⇒ <code>Promise</code>
* [.tickers(symbols, cb)](#RESTv2+tickers) ⇒ <code>Promise</code>
* [.tickersHistory(symbols, start, end, limit, cb)](#RESTv2+tickersHistory) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -87,6 +88,20 @@ Instantiate a new REST v2 transport.
| --- | --- |
| cb | <code>Method</code> |


<a name="RESTv2+statusMessages"></a>

### resTv2.statusMessages(type, keys, cb) ⇒ <code>Promise</code>
**Kind**: instance method of <code>[RESTv2](#RESTv2)</code>
**Returns**: <code>Promise</code> - p
**See**: https://docs.bitfinex.com/v2/reference#status

| Param | Type | Default |
| --- | --- | --- |
| type | <code>string</code> | <code>&quot;deriv&quot;</code> |
| keys | <code>Array [string]</code> | <code>[&quot;ALL&quot;]</code> |
| cb | <code>Method</code> | |

<a name="RESTv2+ticker"></a>

### resTv2.ticker(symbol, cb) ⇒ <code>Promise</code>
Expand Down
17 changes: 16 additions & 1 deletion lib/rest2.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const {
Movement,
LedgerEntry,
UserInfo,
Currency
Currency,
StatusMessagesDeriv
} = require('bfx-api-node-models')

const RESTv1 = require('./rest1')
Expand Down Expand Up @@ -349,6 +350,20 @@ class RESTv2 {
return this._makePublicRequest('/platform/status', cb)
}

/**
* @param {string?} type
* @param {string[]} keys
* @param {Method?} cb
* @return {Promise} p
* @see https://docs.bitfinex.com/v2/reference#status
*/
statusMessages (type = 'deriv', keys = ['ALL'], cb) {
const url = `/status/${type}?keys=${keys.join(',')}`
const transformer = (type === 'deriv') ? StatusMessagesDeriv : null

return this._makePublicRequest(url, cb, transformer)
}

/**
* @param {string} symbol
* @param {Method} cb
Expand Down
1 change: 1 addition & 0 deletions test/lib/rest-2-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('RESTv2 integration (mock server) tests', () => {
['tickersHistory', 'tickers_hist', [['tBTCUSD', 'tETHUSD'], 'start', 'end', 'limit']],
['stats', 'stats.key.context', ['key', 'context']],
['candles', 'candles.trade:30m:tBTCUSD.hist', [{ timeframe: '30m', symbol: 'tBTCUSD', section: 'hist' }]],
['statusMessages', 'status_messages.deriv.ALL', ['deriv', ['ALL']]],

// private
['alertList', 'alerts.price', ['price']],
Expand Down

0 comments on commit 6e20b2a

Please sign in to comment.