All files / lib/resources balance.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                                                       
/**
 * @name Balance
 * @description This module exposes functions
 *              related to the `/balance` path.
 *
 * @module balance
 **/
 
import routes from '../routes'
import request from '../request'
 
/**
 * `GET /balance`
 * Returns company's balance
 *
 * @param {Object} opts An options params which
 *                      is usually already bound
 *                      by `connect` functions.
*/
const primary = opts =>
  request.get(opts, routes.balance.base, {})
 
/**
 * `GET /recipients/:id/balance`
 * Returns the balance of a recipient.
 *
 * @param {Object} opts An options params which
 *                      is usually already bound
 *                      by `connect` functions.
 *
 * @param {Object} body The payload for the request
 * @param {String} body.recipientId The recipient Id
 *
 * @returns {Promise} Resolves to the result of
 *                    the request or to an error.
 */
const find = (opts, body) =>
  request.get(opts, routes.balance.recipient(body.recipientId), body)
 
export default {
  primary,
  find,
}