Skip to content

Commit

Permalink
implements getTrailingVolume
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoputzer committed Jan 7, 2019
1 parent f34bab8 commit c9b778d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ exports.placeOrder = (data, { parse } = JSON, { stringify } = JSON, { env } = pr
body: stringify(data)
}, env).then(toString).then(parse)

exports.getTrailingVolume = (query = {}, { parse } = JSON, { stringify } = querystring, { env } = process, { toString, request } = client) => request({
method: 'get',
path: '/users/self/trailing-volume?' + stringify(query)
}, env).then(toString).then(parse)

exports.cancelOrder = (orderId, query = {}, { parse } = JSON, { stringify } = querystring, { env } = process, { toString, request } = client) => request({
method: 'delete',
path: '/orders/' + orderId + '?' + stringify(query)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coinbase-pro-api",
"version": "0.0.4",
"version": "0.0.5",
"description": "lightweight coinbase pro api implementation",
"main": "index.js",
"config": {
Expand Down
25 changes: 25 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,31 @@ test('coinbase-pro-api', () => {
})
})

test('.getTrailingVolume', () => {
const { getTrailingVolume } = require('..')

test('is of type function', () => {
strictEqual(typeof getTrailingVolume, 'function')
})

test('fetches user trailing volume parses json response', (done) => {
nock('https://api.pro.coinbase.com')
.matchHeader('user-agent', /.*/)
.matchHeader('cb-access-key', /.*/)
.matchHeader('cb-access-passphrase', /.*/)
.matchHeader('cb-access-sign', /.{44}/)
.matchHeader('cb-access-timestamp', /\d{10}\..*/)
.get('/users/self/trailing-volume')
.query({})
.reply(200, [])

getTrailingVolume()
.then(res => deepStrictEqual(res, []))
.then(done)
.catch(done)
})
})

test('.cancelOrder', () => {
const { cancelOrder } = require('..')

Expand Down

0 comments on commit c9b778d

Please sign in to comment.