All files / lib/resources kyc.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                                                                                                                                                                                                 
/**
 * @name Kyc
 * @description This module exposes functions
 *              related to the '/kyc' path.
 *
 * @module kyc
 **/
 
import routes from '../routes'
import request from '../request'
 
/**
  * `GET /recipient/:recipientId/upgrade`
  *
  * Returns requested identity check.
  *
  * @param {Object} opts An options params which
  *                      is usually already bound
  *                      by `connect` functions.
  * @returns {Promise} Resolves to the result of
  *                    the request or to an error.
*/
const findOne = (opts, body) =>
  request.get(opts, routes.kyc.identityCheck.findOne(body.recipientId))
 
/**
  * `POST /recipient/:recipientId/upgrade`
  *
  * Creates a identity check based on an recipientId.
  *
  * @param {Object} opts An options params which
  *                      is usually already bound
  *                      by `connect` functions.
  * @param {String} data An object containing
  *                      the form data
  * @returns {Promise} Resolves to the result of
  *                    the request or to an error.
*/
const create = (opts, body) =>
  request.post(opts, routes.kyc.identityCheck.create(body.recipientId), body)
 
/**
  * `PUT /recipient/:recipientId/upgrade`
  *
  * Updates a identity check based on an recipientId.
  *
  * @param {Object} opts An options params which
  *                      is usually already bound
  *                      by `connect` functions.
  * @param {String} data An object containing
  *                      the form data
  * @returns {Promise} Resolves to the result of
  *                    the request or to an error.
*/
const update = (opts, body) =>
  request.put(opts, routes.kyc.identityCheck.update(body.recipientId), body)
 
/**
  * `POST /recipient/:recipientId/upgrade/identity`
  *
  * Updates a identity check based on an recipientId.
  *
  * @param {Object} opts An options params which
  *                      is usually already bound
  *                      by `connect` functions.
  * @returns {Promise} Resolves to the result of
  *                    the request or to an error.
*/
const upgrade = (opts, body) =>
  request.post(opts, routes.kyc.identityCheck.upgrade(body.recipientId), body)
 
  /**
    * `PUT /recipient/:recipientId/settings`
    *
    * Updates an identity check settings based on an recipientId.
    *
    * @param {Object} opts An options params which
    *                      is usually already bound
    *                      by `connect` functions.
    * @param {String} data An object containing
    *                      the form data
    * @returns {Promise} Resolves to the result of
    *                    the request or to an error.
  */
const updateSettings = (opts, body) =>
  request.put(opts, routes.kyc.identityCheck.updateSettings(body.recipientId), body)
 
export default {
  identityCheck: {
    findOne,
    create,
    update,
    upgrade,
    updateSettings,
  },
}