Skip to content
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

Merged
merged 29 commits into from
Sep 6, 2017

Conversation

dnl-blkv
Copy link
Contributor

@dnl-blkv dnl-blkv commented Sep 3, 2017

No description provided.

Copy link
Contributor

@OGKevin OGKevin left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

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();
Copy link
Contributor

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of "else"?

Copy link
Contributor Author

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 :)

Copy link
Contributor

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()) &&
Copy link
Contributor

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 ?

Copy link
Contributor Author

@dnl-blkv dnl-blkv Sep 4, 2017

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...

Copy link
Contributor

@OGKevin OGKevin Sep 4, 2017

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
Copy link
Contributor

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ma *

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same s above

Copy link
Contributor Author

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;

/**
*/
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generated

@dnl-blkv
Copy link
Contributor Author

dnl-blkv commented Sep 4, 2017

@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 :)

@OGKevin
Copy link
Contributor

OGKevin commented Sep 4, 2017

@dnl-blkv ack, LGTM. Will run tests before I approve. Will make PR tonight for the generated code as well 😉.

@OGKevin
Copy link
Contributor

OGKevin commented Sep 4, 2017

@dnl-blkv all tests passing, please include pagination tests as we discussed and it can be merged 👏

@OGKevin OGKevin modified the milestone: v0.11.0 Sep 5, 2017
Copy link
Contributor

@OGKevin OGKevin left a 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;
Copy link
Contributor

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 ?

Copy link
Contributor Author

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 =
Copy link
Contributor

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?

Copy link
Contributor Author

@dnl-blkv dnl-blkv Sep 5, 2017

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() {
Copy link
Contributor

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 ?

Copy link
Contributor Author

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()
Copy link
Contributor

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 ?

Copy link
Contributor Author

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?

Copy link
Contributor

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 ?

Copy link
Contributor Author

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 :)

@OGKevin
Copy link
Contributor

OGKevin commented Sep 5, 2017

All tests passing, LGTM @andrederoos please take a look.

@andrederoos andrederoos changed the title Add pagination; cleanup; add missing endpoitns and fields [#4] Add pagination; cleanup; add missing endpoints and fields [#4] Sep 6, 2017
Copy link
Contributor

@andrederoos andrederoos left a 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.

@dnl-blkv
Copy link
Contributor Author

dnl-blkv commented Sep 6, 2017

@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.

@andrederoos
Copy link
Contributor

awesome!

@andrederoos andrederoos merged commit 1740c8b into develop Sep 6, 2017
@andrederoos andrederoos deleted the 4-pagination branch September 6, 2017 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants