Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ai.pluggy</groupId>
<artifactId>pluggy-java</artifactId>
<version>1.16.0</version>
<version>1.16.1</version>

<packaging>jar</packaging>

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/ai/pluggy/client/response/AccountBalance.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@
@AllArgsConstructor
public class AccountBalance {

/** Available balance, same as {@code balance} in the account resource. */
Double balance;
/** Amount currently blocked or held on the account. Null when the institution does not report it. */
Double blockedBalance;
/** Amount held in the account's automatic investment facility. Null when not reported. */
Double automaticallyInvestedBalance;
/**
* Accounting balance: {@code balance + blockedBalance}. Same value as {@code bankData.closingBalance}
* in the account resource, which the API refreshes with it. Null when the institution does not report it.
*/
Double closingBalance;
String currencyCode;
/** ISO-8601 timestamp of when the institution last updated the balance. */
String updateDateTime;
Expand Down
23 changes: 21 additions & 2 deletions src/test/java/ai/pluggy/client/unit/TransactionsV2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,35 @@ void parseAfterCursor_handlesEdgeCases() {

@Test
void getAccountBalance_parsesBalance() throws IOException {
responseJson = "{\"balance\":1523.47,\"currencyCode\":\"BRL\","
+ "\"updateDateTime\":\"2026-10-01T10:15:00.000Z\"}";
responseJson = "{\"balance\":1523.47,\"blockedBalance\":100.25,"
+ "\"automaticallyInvestedBalance\":92119.12,\"closingBalance\":1623.72,"
+ "\"currencyCode\":\"BRL\",\"updateDateTime\":\"2026-10-01T10:15:00.000Z\"}";

AccountBalance balance = client.service().getAccountBalance(ACCOUNT_ID).execute().body();

assertEquals("GET", lastRequest.method());
assertEquals("/accounts/" + ACCOUNT_ID + "/balance", lastRequest.url().encodedPath());
assertNotNull(balance);
assertEquals(1523.47, balance.getBalance());
assertEquals(100.25, balance.getBlockedBalance());
assertEquals(92119.12, balance.getAutomaticallyInvestedBalance());
assertEquals(1623.72, balance.getClosingBalance());
assertEquals("BRL", balance.getCurrencyCode());
assertEquals("2026-10-01T10:15:00.000Z", balance.getUpdateDateTime());
}

@Test
void getAccountBalance_optionalBalancesAreNullWhenAbsent() throws IOException {
// The API omits these amounts when the institution does not report them.
responseJson = "{\"balance\":1523.47,\"currencyCode\":\"BRL\","
+ "\"updateDateTime\":\"2026-10-01T10:15:00.000Z\"}";

AccountBalance balance = client.service().getAccountBalance(ACCOUNT_ID).execute().body();

assertNotNull(balance);
assertEquals(1523.47, balance.getBalance());
assertNull(balance.getBlockedBalance());
assertNull(balance.getAutomaticallyInvestedBalance());
assertNull(balance.getClosingBalance());
}
}
Loading