[capital] Code generation: update services and models#1793
[capital] Code generation: update services and models#1793AdyenAutomationBot wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello, 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 updates the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request introduces new API models and a client for "Dynamic Offers" within the Capital API, including CalculateGrantOfferRequest, CalculatedGrantOffer, CreateGrantOfferRequest, DynamicOffer, DynamicOfferRepayment, GetDynamicOffersResponse, and DynamicOffersApi. It renames the AdditionalBankIdentificationTypes enum to FinancingType with new values, and refactors AdditionalBankIdentification to use an inner TypeEnum for bank identification types. Javadoc across several existing Grant and GrantOffer related models and API clients is updated to clarify terminology, changing "grant offer" to "offer" or "static offer". The updateDescription field and its methods in DisbursementRepayment and DisbursementRepaymentInfoUpdate are deprecated, and fields in InvalidField are reordered. Review comments suggest improving enum implementations by removing redundant String.valueOf() calls, optimizing fromValue methods with static maps for better performance, making Javadoc parameter descriptions more concise, removing redundant // deprecated comments, and adding explanations to @deprecated Javadoc tags.
Note: Security Review is unavailable for this PR.
| AUBSBCODE(String.valueOf("auBsbCode")), | ||
|
|
||
| CAROUTINGNUMBER(String.valueOf("caRoutingNumber")), | ||
|
|
||
| GBSORTCODE(String.valueOf("gbSortCode")), | ||
|
|
||
| USROUTINGNUMBER(String.valueOf("usRoutingNumber")); |
There was a problem hiding this comment.
The String.valueOf() calls are redundant as the arguments are already strings. This can be simplified. This pattern appears in other enums in this PR as well (e.g., CalculatedGrantOffer.ContractTypeEnum, DynamicOffer.ContractTypeEnum).
| AUBSBCODE(String.valueOf("auBsbCode")), | |
| CAROUTINGNUMBER(String.valueOf("caRoutingNumber")), | |
| GBSORTCODE(String.valueOf("gbSortCode")), | |
| USROUTINGNUMBER(String.valueOf("usRoutingNumber")); | |
| AUBSBCODE("auBsbCode"), | |
| CAROUTINGNUMBER("caRoutingNumber"), | |
| GBSORTCODE("gbSortCode"), | |
| USROUTINGNUMBER("usRoutingNumber"); |
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.valueOf(value); |
| public static TypeEnum fromValue(String value) { | ||
| for (TypeEnum b : TypeEnum.values()) { | ||
| if (b.value.equals(value)) { | ||
| return b; | ||
| } | ||
| } | ||
| // handling unexpected value | ||
| LOG.warning( | ||
| "TypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(TypeEnum.values())); | ||
| return null; | ||
| } |
There was a problem hiding this comment.
The fromValue method uses a linear search over the enum values. For better performance, especially if the number of enum constants grows, consider using a static map for an O(1) lookup. This is a recurring pattern in other enums in this PR.
Example implementation:
private static final Map<String, TypeEnum> VALUE_MAP = new HashMap<>();
static {
for (TypeEnum e : values()) {
VALUE_MAP.put(e.value, e);
}
}
@JsonCreator
public static TypeEnum fromValue(String value) {
TypeEnum enumValue = VALUE_MAP.get(value);
if (enumValue == null) {
LOG.warning(
"TypeEnum: unexpected enum value '"
+ value
+ "' - Supported values are "
+ Arrays.toString(TypeEnum.values()));
}
return enumValue;
}| * @param type The type of additional bank identification, depending on the country. Possible | ||
| * values: * **auBsbCode**: The 6-digit [Australian Bank State Branch (BSB) | ||
| * code](https://en.wikipedia.org/wiki/Bank_state_branch), without separators or spaces. * | ||
| * **caRoutingNumber**: The 9-digit [Canadian routing | ||
| * number](https://en.wikipedia.org/wiki/Routing_number_(Canada)), in EFT format, without | ||
| * separators or spaces. * **gbSortCode**: The 6-digit [UK sort | ||
| * code](https://en.wikipedia.org/wiki/Sort_code), without separators or spaces * | ||
| * **usRoutingNumber**: The 9-digit [routing | ||
| * number](https://en.wikipedia.org/wiki/ABA_routing_transit_number), without separators or | ||
| * spaces. |
There was a problem hiding this comment.
The Javadoc for the type parameter is a verbatim copy of the method's main description. This is redundant and makes the documentation harder to read. The parameter description should be more concise, for example: @param type The type of additional bank identification. This pattern of verbose and repetitive Javadoc is present for other methods and classes in this pull request.
| private boolean isSetBasisPoints = false; | ||
|
|
||
| public static final String JSON_PROPERTY_UPDATE_DESCRIPTION = "updateDescription"; | ||
| @Deprecated // deprecated |
| * | ||
| * @param updateDescription | ||
| * @return the current {@code DisbursementRepayment} instance, allowing for method chaining | ||
| * @deprecated |
64ac0ab to
28819fb
Compare
This PR contains the automated changes for the
capitalservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.