Balance
The Balance proto object represents an account's balance, both current and available, identified by its account_id.
Balance {
string account_id = 1;
io.token.proto.common.money.Money current = 2;
io.token.proto.common.money.Money available = 3;
int64 updated_at_ms = 4;
TypedBalance other_balances = 5; // optional
TypedBalance {
string type = 1;
io.token.proto.common.money.Money amount = 2;
int64 updated_at_ms = 3;
}
}
The optional TypedBalance identifies other balances linked to the account_id; could include savings (for overdraft protection), line(s) of credit, and so forth, as defined by the bank in type.
The Java object for Balance takes this form:
package io.token.sdk.api;
import com.google.auto.value.AutoValue;
import io.token.proto.common.transaction.TransactionProtos.Balance.TypedBalance;
import java.math.BigDecimal;
import java.util.List;
/**
* Represents account balance.
*/
@AutoValue
public abstract class Balance {
/**
* Creates new balance instance.
*
* @param currency currency
* @param available available balance
* @param current current balance
* @param updatedAtMs date of last update
* @param otherBalances other optional typed balances
* @return new balance instance
*/
public static Balance create(
String currency,
BigDecimal available,
BigDecimal current,
long updatedAtMs,
List<TypedBalance> otherBalances) {
return new AutoValue_Balance(currency, available, current, updatedAtMs, otherBalances);
}
/**
* Returns account currency.
*
* @return account currency
*/
public abstract String getCurrency();
/**
* Returns available balance.
*
* @return available balance
*/
public abstract BigDecimal getAvailable();
/**
* Returns current balance.
*
* @return current balance
*/
public abstract BigDecimal getCurrent();
/**
* Returns date of last update.
*
* @return date of last update
*/
public abstract long getUpdatedAtMs();
/**
* Returns list of other optional typed balances.
*
* @return list of other balances
*/
public abstract List<TypedBalance> getOtherBalances();
}