UNPKG

starkinfra

Version:

SDK to facilitate Node integrations with Stark Infra

107 lines (99 loc) 4.11 kB
const rest = require('../../utils/rest.js'); const check = require('starkcore').check; const Resource = require('../../utils/resource.js').Resource class Log extends Resource { /** * * PixDispute.Log object * * @description Every time a PixDispute entity is modified, a corresponding PixDispute.Log * is generated for the entity. This log is never generated by the user. * * Attributes: * @param id [string]: unique id returned when the log is created. ex: "5656565656565656" * @param created [string]: creation datetime for the log. ex: "2020-03-29" * @param type [string]: type of the PixDispute event which triggered the log creation. ex: "created" * @param errors [list of strings]: list of errors linked to this PixDispute event * @param dispute [PixDispute]: PixDispute entity to which the log refers to. */ constructor({ id=null, created=null, type=null, errors=null, dispute=null }) { super(id); this.created = check.datetime(created); this.type = type; this.errors = errors; this.dispute = dispute; } } exports.Log = Log; let resource = {'class': exports.Log, 'name': 'PixDisputeLog'}; exports.get = async function (id, {user} = {}) { /** * * Retrieve a specific PixDispute Log * * @description Receive a single PixDispute Log object previously created by the Stark Infra API by passing 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 starkinfra.user was set before function call * * Return: * @returns PixDispute Log object with updated attributes * */ return rest.getId(resource, id, user); }; exports.query = async function ({limit, after, before, types, ids, disputeIds, user} = {}) { /** * * Retrieve PixDispute Logs * * @description Receive a generator of PixDispute Log objects previously created in the Stark Infra 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 retrieved objects by types. ex: 'success' or 'failed' * @param ids [list of strings, default null]: list of PixDispute.Log ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param disputeIds [list of strings, default null]: list of PixDispute ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call * * Return: * @returns list of PixDispute Log objects with updated attributes * */ let query = { limit: limit, after: after, before: before, types: types, ids: ids, disputeIds: disputeIds, }; return rest.getList(resource, query, user); }; exports.page = async function ({cursor, limit, after, before, types, ids, disputeIds, user} = {}) { /** * * Retrieve paged PixDispute Logs * * @description Receive a list of up to 100 PixDispute.Log objects previously created in the Stark Infra API and the cursor to the next page. * Use this function instead of query if you want to manually page your disputes. * */ let query = { cursor: cursor, limit: limit, after: after, before: before, types: types, ids: ids, disputeIds: disputeIds, }; return rest.getPage(resource, query, user); };