'use strict'

const _chunk = require('lodash/chunk')
const runExample = require('../util/run_example')

module.exports = runExample({
  name: 'rest-get-currencies',
  rest: true
}, async ({ debug, rest }) => {
  debug('fetching currency list...')

  const currencies = await rest.currencies()

  debug('received %d currencies', currencies[0].length)

  debug('')
  _chunk(currencies[0], 10).forEach((currencyChunk) => {
    debug('%s', currencyChunk.join(', '))
  })
  debug('')
})

'use strict'

const _chunk = require('lodash/chunk')
const { RESTv2 } = require('bfx-api-node-rest')
const { args: { apiKey, apiSecret }, debug } = require('../util/setup')

async function execute () {
  const rest = new RESTv2({
    apiKey,
    apiSecret
  })
  debug('fetching currency list...')

  const currencies = await rest.currencies()

  debug('received %d currencies', currencies[0].length)

  debug('')
  _chunk(currencies[0], 10).forEach((currencyChunk) => {
    debug('%s', currencyChunk.join(', '))
  })
  debug('')
}

execute()

update 'currencies' example