diff --git a/src/main/java/com/plaid/client/request/AssetReportGetRequest.java b/src/main/java/com/plaid/client/request/AssetReportGetRequest.java index d482064383..05dab63c2e 100644 --- a/src/main/java/com/plaid/client/request/AssetReportGetRequest.java +++ b/src/main/java/com/plaid/client/request/AssetReportGetRequest.java @@ -4,8 +4,14 @@ public final class AssetReportGetRequest extends BaseClientRequest { private String assetReportToken; + private boolean includeInsights = false; public AssetReportGetRequest(String assetReportToken) { this.assetReportToken = assetReportToken; } + + public AssetReportGetRequest withIncludeInsights(boolean includeInsights) { + this.includeInsights = includeInsights; + return this; + } } diff --git a/src/main/java/com/plaid/client/response/AssetReportGetResponse.java b/src/main/java/com/plaid/client/response/AssetReportGetResponse.java index e38a2fae91..fe5a1e213b 100644 --- a/src/main/java/com/plaid/client/response/AssetReportGetResponse.java +++ b/src/main/java/com/plaid/client/response/AssetReportGetResponse.java @@ -4,8 +4,11 @@ import java.util.List; import java.util.Objects; +import com.plaid.client.response.TransactionsGetResponse.Transaction.Location; +import com.plaid.client.response.TransactionsGetResponse.Transaction.PaymentMeta; + /** - * See https://plaid.com/docs/api/#assets for more detail into the returned schema + * See https://plaid.com/docs/#assets for more detail into the returned schema. **/ public class AssetReportGetResponse extends BaseResponse { private AssetReport report; @@ -535,6 +538,19 @@ public static final class Transaction { private String unofficialCurrencyCode; private String isoCurrencyCode; + // The following fields are only included in an Asset Report with Insights. + // For more information, see + // https://plaid.com/docs/#retrieve-json-report-request. + private String accountOwner; + private List category; + private String categoryId; + private String dateTransacted; + private Location location; + private String name; + private PaymentMeta paymentMeta; + private String pendingTransactionId; + private String transactionType; + public String getAccountId() { return accountId; } @@ -567,6 +583,42 @@ public String getIsoCurrencyCode() { return isoCurrencyCode; } + public String getAccountOwner() { + return accountOwner; + } + + public List getCategory() { + return category; + } + + public String getCategoryId() { + return categoryId; + } + + public String getDateTransacted() { + return dateTransacted; + } + + public Location getLocation() { + return location; + } + + public String getName() { + return name; + } + + public PaymentMeta getPaymentMeta() { + return paymentMeta; + } + + public String getPendingTransactionId() { + return pendingTransactionId; + } + + public String getTransactionType() { + return transactionType; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -583,13 +635,23 @@ public boolean equals(Object obj) { Objects.equals(pending, that.pending) && Objects.equals(amount, that.amount) && Objects.equals(unofficialCurrencyCode, that.unofficialCurrencyCode) && - Objects.equals(isoCurrencyCode, that.isoCurrencyCode); + Objects.equals(isoCurrencyCode, that.isoCurrencyCode) && + Objects.equals(accountOwner, that.accountOwner) && + Objects.equals(category, that.category) && + Objects.equals(categoryId, that.categoryId) && + Objects.equals(dateTransacted, that.dateTransacted) && + Objects.equals(location, that.location) && + Objects.equals(name, that.name) && + Objects.equals(paymentMeta, that.paymentMeta) && + Objects.equals(pendingTransactionId, that.pendingTransactionId) && + Objects.equals(transactionType, that.transactionType); } @Override public int hashCode() { return Objects.hash(accountId, transactionId, date, originalDescription, pending, amount, - unofficialCurrencyCode, isoCurrencyCode); + unofficialCurrencyCode, isoCurrencyCode, accountOwner, category, categoryId, + dateTransacted, location, name, paymentMeta, pendingTransactionId, transactionType); } } diff --git a/src/test/java/com/plaid/client/integration/AssetReportGetTest.java b/src/test/java/com/plaid/client/integration/AssetReportGetTest.java index 5e77a7844b..1b46a3f549 100644 --- a/src/test/java/com/plaid/client/integration/AssetReportGetTest.java +++ b/src/test/java/com/plaid/client/integration/AssetReportGetTest.java @@ -46,6 +46,21 @@ public void testAssetReportGetSuccess() throws Exception { assertFalse(respBody.getReport().getItems().isEmpty()); assertNotNull(respBody.getReport().getAssetReportId()); + + // Retrieve the report as an Asset Report with Insights. + AssetReportGetRequest assetReportGet = + new AssetReportGetRequest(assetReportToken) + .withIncludeInsights(true); + response = client().service().assetReportGet(assetReportGet).execute(); + + respBody = response.body(); + assertSuccessResponse(response); + + assertNotNull(respBody.getReport()); + + // An Asset Report with Insights should include a name (when available). + assertNotNull(respBody.getReport().getItems().get(0).getAccounts().get(0).getTransactions() + .get(0).getName()); } /** @@ -58,7 +73,8 @@ public static Response waitTillReady( int attempt = 0; Response response; do { - AssetReportGetRequest assetReportGet = new AssetReportGetRequest(assetReportToken); + AssetReportGetRequest assetReportGet = + new AssetReportGetRequest(assetReportToken); response = client.service().assetReportGet(assetReportGet).execute(); attempt++; Thread.sleep(INTER_REQUEST_SLEEP);