-
Notifications
You must be signed in to change notification settings - Fork 144
Generate Balance Webhooks models #1607
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
Conversation
Summary of ChangesHello @gcatanese, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the Adyen Java API library's capabilities by integrating new Balance Webhook models. It specifically introduces support for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces new models for Balance Webhooks, specifically for the balancePlatform.balanceAccount.balance.block.released event, and updates existing models to better handle nullable values. The changes, mostly auto-generated, are consistent and well-structured. The inclusion of a new handler method and a corresponding test case for the new webhook type is a great addition. I've identified a couple of minor areas for improvement in the generated code to enhance readability and efficiency.
src/main/java/com/adyen/model/balancewebhooks/BalanceWebhooksHandler.java
Show resolved
Hide resolved
src/main/java/com/adyen/model/balancewebhooks/ReleasedBlockedBalanceNotificationRequest.java
Show resolved
Hide resolved
galesky-a
left a comment
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.
Overall LGTM but similar concern as here: #1605 (comment)
d23a6e9 to
b379579
Compare
|
/gemini review |
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.
Code Review
This pull request introduces new models for Balance Webhooks, specifically for the balancePlatform.balanceAccount.balance.block.released event. The changes include new auto-generated model classes, a new handler method in BalanceWebhooksHandler, and a corresponding test case with mock data. The code generation seems to be working correctly, and the new functionality is well-tested. I have one suggestion regarding the implementation of the new handler method to improve code conciseness and maintainability.
| public Optional<ReleasedBlockedBalanceNotificationRequest> | ||
| getReleasedBlockedBalanceNotificationRequest() { | ||
|
|
||
| var optionalReleasedBlockedBalanceNotificationRequest = | ||
| getOptionalField(ReleasedBlockedBalanceNotificationRequest.class); | ||
|
|
||
| if (optionalReleasedBlockedBalanceNotificationRequest.isPresent()) { | ||
| // verify event type | ||
| for (var value : ReleasedBlockedBalanceNotificationRequest.TypeEnum.values()) { | ||
| if (value.equals(optionalReleasedBlockedBalanceNotificationRequest.get().getType())) { | ||
| // found matching event type | ||
| return optionalReleasedBlockedBalanceNotificationRequest; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return Optional.empty(); | ||
| } |
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.
The logic in this new method getReleasedBlockedBalanceNotificationRequest is a bit verbose and includes a redundant loop to verify the event type. During deserialization, Jackson uses the fromValue method in the TypeEnum, which returns null for an invalid type from the JSON payload. Therefore, a simple null check on getType() is sufficient.
This can be simplified significantly using Optional.filter. Since this code is likely auto-generated from a template (webhook_handler.mustache), I recommend updating the template to generate more concise and efficient code for all such handler methods. This would also help reduce code duplication with getBalanceAccountBalanceNotificationRequest.
public Optional<ReleasedBlockedBalanceNotificationRequest>
getReleasedBlockedBalanceNotificationRequest() {
return getOptionalField(ReleasedBlockedBalanceNotificationRequest.class)
.filter(req -> req.getType() != null);
}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.
Added to the backlog
|
@galesky-a I have rebased with |
PR to generate the BalanceWebhooks models.
Transfer Webhooks
balancePlatform.balanceAccount.balance.block.released