-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination; cleanup; add missing endpoints and fields [#4] #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of remarks and questions 🤔 🔍
/** | ||
* Constants to be changed to run the example. | ||
*/ | ||
private static final int USER_ITEM_ID = 1969; // Put your user ID here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These ids can be put to zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
* Constants to be changed to run the example. | ||
*/ | ||
private static final int USER_ITEM_ID = 1969; // Put your user ID here | ||
private static final int MONETARY_ACCOUNT_ITEM_ID = 1988; // Put your monetary account ID here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
public Pagination deserialize(JsonElement json, Type typeOfT, | ||
JsonDeserializationContext context) throws JsonParseException { | ||
try { | ||
JsonObject responseJson = json.getAsJsonObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This try
block is kinds big, wouldnt it be a beter idea to only put the line that will throw the exception in the try
block and put the rest in the else
block?
Or are you expecting the exception on all these lines ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of "else"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I'll just extract a method from it and it'll become smaller :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try:
b
except:
do stuff if exception caught
else:
do stuff if no exception
This way it's clear what is throwing the exception. That is what I meant with the `else's not sure if java has such thing though 🙈 just took a guess here 😁
for (NameValuePair param : params) { | ||
if (responseParam.equals(param.getName())) { | ||
paginationBody.put(idField, Integer.parseInt(param.getValue())); | ||
} else if (Pagination.PARAM_COUNT.equals(param.getName()) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using if
and else if
isn't an else
expected ? Why not just write 2 `if statements ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if
just makes it more clear that it is one or the other
Else is not OK because if SOMETHING different occurs (some other return value of param.getName()
), we will mistakenly process it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You kinda misunderstood me haha, but your first sentacne explains it well 👍
In python if you use else if
, an else
statement is required, that's more what I meant 😁. This will force you to then write 2 if
statements instead.
@@ -162,6 +162,14 @@ | |||
@SerializedName("pin_code_assignment") | |||
private List<CardPinAssignment> pinCodeAssignment; | |||
|
|||
/** | |||
* ID of the MA to be used as fallback for this card if insufficient balance. Fallback account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't `MAD be spelled out completely ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ma
*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
public CardLimit(String dailyLimit, String currency, String type) { | ||
this.dailyLimit = dailyLimit; | ||
this.currency = currency; | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* The id of the card limit entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as comment above, consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
private Boolean allowBunqto; | ||
|
||
/** | ||
* The id of the draft payment entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
, please convert to uppercase or change the uppercase ones to lower case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
} | ||
|
||
/** | ||
* The id of the draft payment entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same s above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intended that this class has an empty comment doc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
@@ -117,4 +124,15 @@ public void setBunqMe(MonetaryAccountReference bunqMe) { | |||
this.bunqMe = bunqMe; | |||
} | |||
|
|||
/** | |||
* Whether or not the monetary account is light. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this line and the comment above, space between monetary
and account
. For consistency, should it be MonetaryAccount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated
@OGKevin All fixed! For all the generated files, let's remember it and look into it later / fix all the docs in the proper place :) |
@dnl-blkv ack, LGTM. Will run tests before I approve. Will make PR tonight for the generated code as well 😉. |
@dnl-blkv all tests passing, please include pagination tests as we discussed and it can be merged 👏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments 🤔
private static final String FIELD_NEWER_URL = "newer_url"; | ||
private static final String FIELD_FUTURE_URL = "future_url"; | ||
|
||
private Integer olderId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't these need a comment doc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Private properties don't really need it.
BunqResponse<List<Payment>> paymentResponsePrevious = | ||
ListPayments(paginationLatest.getUrlParamsPreviousPage()); | ||
Pagination paginationPrevious = paymentResponsePrevious.getPagination(); | ||
BunqResponse<List<Payment>> paymentResponsePreviousNext = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be called paymentResponseNext
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is not next. It is next in relation to the previous. So, current. However, we care about the way we've reached it. Thus, it is previousNext
.
public final ExpectedException exception = ExpectedException.none(); | ||
|
||
@Test | ||
public void getUrlParamsCountOnlyTest() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comments count for this entire file. In the other tests there are comment docs on each test briefly explaining what this test is actually testing. Don't we want to keep doing this for consistency ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explained above, in a comment for PaginationScenarioTest
private static Gson gson = BunqGsonBuilder.buildDefault().create(); | ||
|
||
@Test | ||
public void apiScenarioPaymentListingWithPaginationTest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other tests there are comment docs on each test briefly explaining what this test is actually testing. Don't we want to keep doing this for consistency ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we probably wanna get rid of them whenever they are obvious. This one is quite straightforward, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be a separate pr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we will clean things up gradually as we develop the SDKs, switching between "ADD ALL THE FEATURES" mode and cleanup mode :)
All tests passing, LGTM @andrederoos please take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should find a structure to skip the generated code in the PR. do a commit (without generated), review, patch with generated, merge.
@andrederoos no need for this magic; @OGKevin already found that way. It is just an old PR. In the future PRs, the generated code will be auto-collapsed. |
awesome! |
No description provided.