starkinfra
Version:
SDK to facilitate Node integrations with Stark Infra
52 lines (45 loc) • 1.85 kB
JavaScript
const rest = require('../utils/rest.js');
const check = require('starkcore').check;
const Resource = require('starkcore').Resource;
class PixBalance extends Resource {
/**
*
* PixBalance object
*
* @description The PixBalance object displays the current 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 PixBalance is created. ex: '5656565656565656'
* @param amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
* @param currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL'
* @param updated [string]: datetime for the PixBalance. ex: '2020-03-10 10:30:00.000'
*
*/
constructor(id, amount, currency, updated) {
super(id);
this.amount = amount;
this.currency = currency;
this.updated = check.datetime(updated);
}
}
exports.PixBalance = PixBalance;
let resource = {'class': exports.PixBalance, 'name': 'PixBalance'};
exports.get = async function ({user} = {}) {
/**
*
* Retrieve the PixBalance object
*
* @description Receive the Balance object linked to your workspace in the Stark Infra API
*
* Parameters (optional):
* @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call
*
* Return:
* @returns PixBalance object with updated attributes
*
*/
let PixBalance = await rest.getList(resource, 100, user).next();
return PixBalance['value'];
};