UNPKG

starkbank

Version:

SDK to facilitate Node integrations with Stark Bank

157 lines (145 loc) 7.88 kB
declare module 'starkbank' { export class Transaction { /** * * Transaction object * * @description A Transaction is a transfer of funds between workspaces inside Stark Bank. * Transactions created by the user are only for internal transactions. * Other operations (such as transfer or charge-payment) will automatically * create a transaction for the user which can be retrieved for the statement. * When you initialize a Transaction, the entity will not be automatically * created in the Stark Bank API. The 'create' function sends the objects * to the Stark Bank API and returns the list of created objects. * * Parameters (required): * @param amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34) * @param description [string]: text to be displayed in the receiver and the sender statements (Min. 10 characters). ex: 'funds redistribution' * @param externalId [string]: unique id, generated by user, to avoid duplicated transactions. ex: 'transaction ABC 2020-03-30' * @param receivedId [string]: unique id of the receiving workspace. ex: '5656565656565656' * * Parameters (optional): * @param tags [list of strings, default null]: list of strings for reference when searching transactions (may be empty). ex: ['abc', 'test'] * * Attributes (return-only): * @param senderId [string]: unique id of the sending workspace. ex: '5656565656565656' * @param source [string]: unique locator of the related entity in the API reference * @param id [string]: unique id returned when Transaction is created. ex: '7656565656565656' * @param fee [integer]: fee charged when the transaction is created. ex: 200 (= R$ 2.00) * @param balance [integer]: account balance after transaction was processed. ex: 100000000 (= R$ 1,000,000.00) * @param created [string]: creation datetime for the transaction. ex: '2020-03-10 10:30:00.000' * */ amount: number description: string externalId: string receiverId: string tags: string[] | null readonly senderId : string readonly id : string readonly fee : number readonly source : string readonly balance : number readonly created : string constructor(params: { amount: number, description: string, externalId: string, receiverId: string, tags?: string[] | null, senderId?: string | null, id?: string | null, fee?: number | null, source?: string | null, balance?: number | null, created?: string | null, }) } export namespace transaction { /** * * Create Transactions * * @description Send a list of Transaction objects for creation in the Stark Bank API * * Parameters (required): * @param transactions [list of Transaction objects]: list of Transaction objects to be created in the API * * Parameters (optional): * @param user [Organization/Project object]: Organization or Project object. Not necessary if starkbank.user was set before function call * * Return: * @returns list of Transaction objects with updated attributes * */ function create(transactions: Transaction[], params?:{ user?: Project | Organization | null}): Promise<Transaction[]>; /** * * Retrieve a specific Transaction * * @description Receive a single Transaction object previously created in the Stark Bank API by passing its id * * Parameters (required): * @param id [string]: object unique id. ex: '5656565656565656' * * Parameters (optional): * @param user [Organization/Project object]: Organization or Project object. Not necessary if starkbank.user was set before function call * * Return: * @returns Transaction object with updated attributes * */ function get(id: string, params?:{ user?: Project | Organization | null}): Promise<Transaction>; /** * * Retrieve paged Transactions * * @description Receive a list of up to 100 Transaction 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 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 tags [list of strings, default null]: tags to filter retrieved objects.ex: ['tony', 'stark'] * @param externalIds [list of strings, default null]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param user [Project object, default null]: Project object. Not necessary if starkbank.user was set before function call * * Return: * @returns list of Transaction objects with updated attributes and cursor to retrieve the next page of Transaction objects * */ function page(params?: { cursor?: string | null, limit?: number | null, after?: string | null, before?: string | null, tags?: string[] | null, externalIds?: string[] | null, ids?: string[] | null, user?: Project | Organization | null }): Promise<[Transaction[], string | null]>; /** * * Retrieve Transactions * * @description Receive a generator of Transaction 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 tags [list of strings, default null]: tags to filter retrieved objects.ex: ['tony', 'stark'] * @param externalIds [list of strings, default null]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] * @param user [Project object, default null]: Project object. Not necessary if starkbank.user was set before function call * * Return: * @returns generator of Transaction objects with updated attributes * */ function query(params?: { limit?: number | null, after?: string | null, before?: string | null, tags?: string[] | null, externalIds?: string[] | null, ids?: string[] | null, user?: Project | Organization | null }): Promise<Transaction[]>; } }