Skip to content

Commit

Permalink
Add limit to Account.Balance
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Feb 9, 2016
1 parent b3fd38c commit 38efffe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/main/java/org/stellar/sdk/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,15 @@ public static class Balance {
private final String assetCode;
@SerializedName("asset_issuer")
private final String assetIssuer;
@SerializedName("limit")
private final String limit;
@SerializedName("balance")
private final String balance;

Balance(String assetType, String assetCode, String assetIssuer, String balance) {
Balance(String assetType, String assetCode, String assetIssuer, String balance, String limit) {
this.assetType = checkNotNull(assetType, "assertType cannot be null");
this.balance = checkNotNull(balance, "balance cannot be null");
this.limit = limit;
this.assetCode = assetCode;
this.assetIssuer = assetIssuer;
}
Expand All @@ -180,6 +183,10 @@ public String getAssetIssuer() {
public String getBalance() {
return balance;
}

public String getLimit() {
return limit;
}
}

/**
Expand Down
18 changes: 16 additions & 2 deletions src/test/java/org/stellar/sdk/AccountDeserializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ public void testDeserialize() {
assertEquals(account.getFlags().getAuthRequired(), false);
assertEquals(account.getFlags().getAuthRevocable(), true);

assertEquals(account.getBalances()[0].getAssetType(), "native");
assertEquals(account.getBalances()[0].getBalance(), "20.0000300");
assertEquals(account.getBalances()[0].getAssetType(), "credit_alphanum4");
assertEquals(account.getBalances()[0].getAssetCode(), "ABC");
assertEquals(account.getBalances()[0].getAssetIssuer(), "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU");
assertEquals(account.getBalances()[0].getBalance(), "1001.0000000");
assertEquals(account.getBalances()[0].getLimit(), "12000.4775807");

assertEquals(account.getBalances()[1].getAssetType(), "native");
assertEquals(account.getBalances()[1].getBalance(), "20.0000300");
assertEquals(account.getBalances()[1].getLimit(), null);

assertEquals(account.getSigners()[0].getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
assertEquals(account.getSigners()[0].getWeight(), 0);
Expand Down Expand Up @@ -77,6 +84,13 @@ public void testDeserialize() {
" },\n" +
" \"balances\": [\n" +
" {\n" +
" \"balance\": \"1001.0000000\",\n" +
" \"limit\": \"12000.4775807\",\n" +
" \"asset_type\": \"credit_alphanum4\",\n" +
" \"asset_code\": \"ABC\",\n" +
" \"asset_issuer\": \"GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU\"\n" +
" },"+
" {\n" +
" \"asset_type\": \"native\",\n" +
" \"balance\": \"20.0000300\"\n" +
" }\n" +
Expand Down

0 comments on commit 38efffe

Please sign in to comment.