starkbank
Version:
SDK to facilitate Node integrations with Stark Bank
50 lines (43 loc) • 2.06 kB
JavaScript
const Resource = require('starkcore').Resource;
const rest = require('../utils/rest.js');
class CorporateBalance extends Resource {
/**
*
* CorporateBalance object
*
* @description The CorporateBalance object displays the current corporate balance of the Workspace,
* which is the result of the sum of all transactions within this
* Workspace. The balance is never generated by the user, but it
* can be retrieved to see the available information.
*
* Attributes (return-only):
* @param id [string]: unique id returned when CorporateBalance is created. ex: "5656565656565656"
* @param amount [integer]: current balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
* @param limit [integer]: The maximum negative balance allowed by the user. ex: 10000 (= R$ 100.00)
* @param maxLimit [integer]: The maximum negative balance allowed by StarkBank. ex: 100000 (= R$ 1000.00)
* @param currency [string]: currency of the current Workspace. Expect others to be added eventually. ex: "BRL"
* @param updated [string] latest update datetime for the CorporateBalance. ex: '2020-03-10 10:30:00.000'
**/
constructor({ id, amount, limit, maxLimit, currency, updated }) {
super(id);
this.amount = amount;
this.limit = limit;
this.maxLimit = maxLimit;
this.currency = currency;
this.updated = updated;
}
}
exports.CorporateBalance = CorporateBalance;
let resource = {'class': exports.CorporateBalance, 'name': 'CorporateBalance'};
exports.get = async function ({user} = {}) {
/**
* Receive the CorporateBalance object linked to your Workspace in the Stark Bank API
* @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkbank.user was set before function call.
*
* Return:
* CorporateBalance object with updated attributes
*
*/
let CorporateBalance = await rest.getList(resource, 100, user).next();
return CorporateBalance['value'];
}