Closed degeusio closed 5 years ago
Update: The bug is caused by a difference between the Java object hierarchy and the hierarchy in the api response. The payment object is nested twice.
Unmarshalling the raw reponse as follows resolves a Payment included in the first 'inquiry_result'.
JsonObject target = jsonObject.getAsJsonArray("Response")
.get(0)
.getAsJsonObject()
.getAsJsonObject("BunqMeTab")
.getAsJsonArray("result_inquiries")
.get(0)
.getAsJsonObject()
.getAsJsonObject("payment")
.getAsJsonObject("Payment") // this is were the bug caused by mapping error java vs. Json is...
);
Payment payment = gson.fromJson(target, Payment.class); //now unmarshals to correct object
Steps to reproduce:
What should happen:
What happens:
Traceback
SDK version and environment
Response id
Extra info:
This is exactly the same issue as reported here for the python sdk
https://together.bunq.com/d/4500-no-payment-details-in-the-result-inquiries-of-a-bunq-me-tab-in-the-api/3
Confirmed that the Raw response DOES contain the expected payment detail. The issue is caused by erroneous unmarshalling here:
BunqModel.java:
protected static BunqResponse fromJson(Class classOfObject, BunqResponseRaw responseRaw, String wrapper) {
JsonObject responseItemObject = getResponseItemObject(responseRaw); // RAW RESPONSE LOOKS OK, CONTAINS THE PAYMENT DETAIL
JsonObject responseItemObjectUnwrapped = getWrappedContent(responseItemObject, wrapper);
T responseValue = gson.fromJson(responseItemObjectUnwrapped, classOfObject); // HERE IT GOES WRONG, PAYMENT DETAIL IS EMPTY
return new BunqResponse(responseValue, responseRaw.getHeaders());
}