From 410045f2792e33a0f799fb1f7a826d1577b513cc Mon Sep 17 00:00:00 2001 From: tmelendez-p Date: Tue, 20 Oct 2026 13:52:56 -0300 Subject: [PATCH] fix: add blockedBalance, automaticallyInvestedBalance and closingBalance to AccountBalance GET /accounts/{id}/balance returns these amounts for Open Finance accounts; Gson dropped them because the DTO did not declare them. Null when the institution does not report them. Bumps the version to 1.16.1 so the release flow publishes it. Co-Authored-By: Claude Fable 5.1 --- pom.xml | 2 +- .../client/response/AccountBalance.java | 10 ++++++++ .../client/unit/TransactionsV2Test.java | 23 +++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 88d0ba9..2389b7c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ ai.pluggy pluggy-java - 1.16.0 + 1.16.1 jar diff --git a/src/main/java/ai/pluggy/client/response/AccountBalance.java b/src/main/java/ai/pluggy/client/response/AccountBalance.java index d49eee2..392474c 100644 --- a/src/main/java/ai/pluggy/client/response/AccountBalance.java +++ b/src/main/java/ai/pluggy/client/response/AccountBalance.java @@ -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; diff --git a/src/test/java/ai/pluggy/client/unit/TransactionsV2Test.java b/src/test/java/ai/pluggy/client/unit/TransactionsV2Test.java index 6ed9da5..126c433 100644 --- a/src/test/java/ai/pluggy/client/unit/TransactionsV2Test.java +++ b/src/test/java/ai/pluggy/client/unit/TransactionsV2Test.java @@ -155,8 +155,9 @@ 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(); @@ -164,7 +165,25 @@ void getAccountBalance_parsesBalance() throws IOException { 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()); + } }