
com.starkinfra.IssuingBalance Maven / Gradle / Ivy
package com.starkinfra;
import com.starkinfra.utils.Rest;
import com.starkinfra.utils.Resource;
import com.starkinfra.utils.Generator;
import java.util.List;
import java.util.HashMap;
import java.util.ArrayList;
public final class IssuingBalance extends Resource {
/**
* IssuingBalance object
*
* The IssuingBalance object displays the current issuing 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.
*
* Parameters:
* id [string]: unique id returned when IssuingBalance is created. ex: "5656565656565656"
* amount [Long]: current issuing balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
* currency [string]: currency of the current workspace. Expect others to be added eventually. ex: "BRL"
* updated [string]: latest update datetime for the IssuingBalance. ex: "2020-03-10 10:30:00.000000+00:00"
*
*/
static ClassData data = new ClassData(IssuingBalance.class, "IssuingBalance");
public Long amount;
public String currency;
public String updated;
/**
* IssuingBalance object
*
* The IssuingBalance object displays the current issuing 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.
*
* Parameters:
* @param id [string]: unique id returned when IssuingBalance is created. ex: "5656565656565656"
* @param amount [Long]: current issuing 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]: latest update datetime for the IssuingBalance. ex: "2020-03-10 10:30:00.000000+00:00"
*/
public IssuingBalance(String id, Long amount, String currency, String updated) {
super(id);
this.amount = amount;
this.currency = currency;
this.updated = updated;
}
/**
* Retrieve the IssuingBalance object
*
* Receive the IssuingBalance object linked to your workspace in the Stark Infra API
*
* Parameters:
* @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.Settings.user was set before function call
*
* Return:
* @return IssuingBalance object with updated attributes
* @throws Exception error in the request
*/
public static IssuingBalance get(User user) throws Exception{
List balanceList = new ArrayList<>();
Generator balances = Rest.getStream(data, new HashMap(), user);
for (IssuingBalance balance : balances) {
balanceList.add(balance);
}
return balanceList.get(0);
}
/**
* Retrieve the Balance object
*
* Receive the Balance object linked to your workspace in the Stark Infra API
*
* Return:
* @return IssuingBalance object with updated attributes
* @throws Exception error in the request
*/
public static IssuingBalance get() throws Exception {
return IssuingBalance.get(null);
}
}