UNPKG

starkbank

Version:

SDK to facilitate Node integrations with Stark Bank

125 lines (112 loc) 5.37 kB
const rest = require('../../utils/rest.js'); const check = require('starkcore').check; const Resource = require('../../utils/resource.js').Resource class Log extends Resource { /** * * corporateholder.Log object * * @description Every time a CorporateHolder entity is updated, a corresponding corporateholder.Log * is generated for the entity. This log is never generated by the * user, but it can be retrieved to check additional information * on the CorporateHolder. * * Attributes (return-only): * @param id [string]: unique id returned when the log is created. ex: "5656565656565656" * @param holder [CorporateHolder]: CorporateHolder entity to which the log refers to. * @param type [string]: type of the CorporateHolder event which triggered the log creation. ex: "blocked", "canceled", "created", "unblocked", "updated" * @param created [string] latest update datetime for the CorporateHolder. ex: '2020-03-10 10:30:00.000' */ constructor({ id, holder, type, created }){ super(id); this.holder = holder; this.type = type; this.created = check.datetime(created); } } exports.Log = Log; let resource = {'class': exports.Log, 'name': 'corporateHolderLog'}; exports.get = async function (id, {user} = {}) { /** * * Retrieve a specific corporateholder.Log * * @description Receive a single corporateholder.Log object previously created by the Stark Bank API by its id * * Parameters (required): * @param id [string]: object unique id. ex: "5656565656565656" * * Parameters (optional): * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkbank.user was set before function call. * * Return: * @return corporateholder.Log object with updated attributes * */ return rest.deleteId(resource, id, user); } exports.query = async function ({limit, after, before, types, holderIds, ids, user} = {}) { /** * * Retrieve corporateholder.Log * * @description Receive a generator of corporateholder.Log objects previously created in the Stark Bank API * * Parameters (optional): * @param limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35 * @param after [string, default null] date filter for objects created only after specified date. ex: '2020-03-10' * @param before [string, default null] date filter for objects created only before specified date. ex: '2020-03-10' * @param types [list of strings, default null]: filter for log event types. ex: ["created", "blocked"] * @param holderIds [list of strings, default null]: list of CorporateHolder ids to filter logs. ex: ["5656565656565656", "4545454545454545"] * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkbank.user was set before function call. * * Return: * @return generator of corporateholder.Log objects with updated attributes * */ let query = { limit: limit, after: check.date(after), before: check.date(before), types: types, holderIds: holderIds, ids: ids, } return rest.getList(resource, query, user); } exports.page = async function ({cursor, limit, after, before, types, holderIds, ids, user} = {}) { /** * * Retrieve paged corporateholder.Log * * @description Receive a list of up to 100 corporateholder.Log objects previously created in the Stark Bank API and the cursor to the next page. * Use this function instead of query if you want to manually page your requests. * * Parameters (optional): * @param cursor [string, default null]: cursor returned on the previous page function call * @param limit [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50 * @param after [string, default null] date filter for objects created only after specified date. ex: '2020-03-10' * @param before [string, default null] date filter for objects created only before specified date. ex: '2020-03-10' * @param types [list of strings, default null]: filter for log event types. ex: ["created", "blocked"] * @param holderids [list of strings, default null]: list of CorporateHolder ids to filter logs. ex: ["5656565656565656", "4545454545454545"] * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkbank.user was set before function call. * @param * * Return: * @return list of corporateholder.Log objects with updated attributes * @return cursor to retrieve the next page of corporateholder.Log objects * */ let query = { cursor: cursor, ids: ids, limit: limit, after: after, before: before, types: types, holderIds: holderIds, } return rest.getPage(resource, query, user); }