All files / lib/resources register.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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100                                                                                                                                                                                                       
/**
 * @name Register
 * @description This module exposes functions
 *              related to the `/register` path.
 *
 * @module Register
 **/
 
import routes from '../routes'
import request from '../request'
 
/**
 * `GET /register/settlement_obligations`
 * Makes a request to /register/settlement_obligations
 *
 * @param {Object} opts An options params which
 *                      is usually already bound
 *                      by `connect` functions.
 *
 * @param {Object} body
 * @param {String} [body.start_date]
 * @param {String} [body.end_date]
 * @param {Number} [body.page]
 * @param {Number} [body.page_size]
 * @param {Number} [body.recipient_id]
*/
const settlementObligations = (opts, body) =>
  request.get(opts, routes.register.settlementObligations.all, body)
 
  /**
   * `GET /register/settlement_obligations/contracts`
   * Makes a request to /register/settlement_obligations/contracts
   *
   * @param {Object} opts An options params which
   *                      is usually already bound
   *                      by `connect` functions.
   *
   * @param {Object} body
   * @param {String} [body.start_date]
   * @param {String} [body.end_date]
   * @param {Number} [body.recipient_id]
  */
const contracts = (opts, body) =>
  request.get(opts, routes.register.settlementObligations.contracts, body)
 
/**
 * `GET /register/contestations`
 * Makes a request to /register/contestations
 *
 * @param {Object} opts An options params which
 *                      is usually already bound
 *                      by `connect` functions.
 *
 * @param {Object} body
 * @param {String} [body.contract_key]
 * @param {Array} [body.range]
*/
const contestations = (opts, body) =>
  request.get(opts, routes.register.contestation.all, body)
 
 
/**
 * `POST /register/contestations`
 * Creates a contestation from the given payload.
 *
 * @param {Object} opts An options params which
 *                      is usually already bound
 *                      by `connect` functions.
 *
 * @param {Object} body
 * @param {Boolean} [body.skip_contract]
 * @param {String} [body.description]
 * @param {Object} [body.author]
 * @param {String} [body.author.email]
 * @param {String} [body.author.system]
 * @param {String} [body.author.user_agent]
 * @param {Object} [body.original_asset_holder]
 * @param {String} [body.original_asset_holder.name]
 * @param {String} [body.original_asset_holder.document]
 * @param {Object} [body.contested]
 * @param {String} [body.contested.name]
 * @param {String} [body.contested.document]
 * @param {Object} [body.target]
 * @param {String} [body.target.key]
 * @param {String} [body.target.type]
 * @param {String} [body.reason_code]
 *
 * @returns {Promise} Resolves to the result of
 *                    the request or to an error.
 */
const createContestation = (opts, body) =>
  request.post(opts, routes.register.contestation.create, body)
 
export default {
  contestations,
  contracts,
  createContestation,
  settlementObligations,
}