Skip to content

[capital] Code generation: update services and models#454

Open
AdyenAutomationBot wants to merge 1 commit intomainfrom
sdk-automation/capital
Open

[capital] Code generation: update services and models#454
AdyenAutomationBot wants to merge 1 commit intomainfrom
sdk-automation/capital

Conversation

@AdyenAutomationBot
Copy link
Collaborator

This PR contains the automated changes for the capital service.

The commit history of this PR reflects the adyen-openapi commits that have been applied.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 expands the capital service by integrating a new DynamicOffersApi, which enables advanced offer management capabilities. Concurrently, it streamlines the codebase by refactoring existing API method calls across several files, enhancing maintainability and consistency. The changes are part of an automated update process reflecting recent adyen-openapi commits.

Highlights

  • New API Service: A new DynamicOffersApi has been introduced within the capital service, providing functionalities to calculate preliminary offers, create static offers, and retrieve all available dynamic offers.
  • API Client Integration: The main AdyenCapitalApi class has been updated to include and initialize the newly added DynamicOffersApi.
  • Code Refactoring: Existing API calls across grant_accounts_api.py, grant_offers_api.py, and grants_api.py have been refactored for improved conciseness and readability.
  • Documentation Update: Docstrings in grant_offers_api.py were updated to clarify references to 'grant offers' as 'static offers'.

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

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR contains the automated changes for the capital service. The changes primarily involve adding the new DynamicOffersApi, updating documentation to reflect API changes (e.g., 'grant offers' to 'static offers'), and applying code formatting for consistency. My review highlights a couple of opportunities for improvement in the auto-generated code, specifically regarding the duplication of a base URL and the use of id as a parameter name, which shadows a Python built-in. Addressing these in the code generator would enhance code quality and maintainability.

def __init__(self, client=None):
super().__init__(client=client)
self.service = "capital"
self.baseUrl = "https://balanceplatform-api-test.adyen.com/capital/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The baseUrl is hardcoded here and duplicated across other API classes in the capital service (e.g., GrantAccountsApi, GrantOffersApi, GrantsApi). This appears to be a pattern from the code generator. To improve maintainability and reduce redundancy, consider defining this URL as a constant in a shared location, like Adyen/services/capital/__init__.py, and referencing it from all capital service API classes. This would centralize the configuration and make future updates easier.

Comment on lines +16 to +20
def calculate_preliminary_offer_from_dynamic_offer(self, request, id, idempotency_key=None, **kwargs):
"""
Calculate a preliminary offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{id}/calculate"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parameter id shadows the built-in function id(). While this might be due to the code being auto-generated, it's a violation of PEP 8 guidelines and can lead to confusion. It would be best to rename it to something more descriptive, like offer_id. This change would need to be propagated to where it's used inside the method.

Suggested change
def calculate_preliminary_offer_from_dynamic_offer(self, request, id, idempotency_key=None, **kwargs):
"""
Calculate a preliminary offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{id}/calculate"
def calculate_preliminary_offer_from_dynamic_offer(self, request, offer_id, idempotency_key=None, **kwargs):
"""
Calculate a preliminary offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{offer_id}/calculate"

Comment on lines +24 to +28
def create_static_offer_from_dynamic_offer(self, request, id, idempotency_key=None, **kwargs):
"""
Create a static offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{id}/grantOffer"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parameter id shadows the built-in function id(). While this might be due to the code being auto-generated, it's a violation of PEP 8 guidelines and can lead to confusion. It would be best to rename it to something more descriptive, like offer_id.

Suggested change
def create_static_offer_from_dynamic_offer(self, request, id, idempotency_key=None, **kwargs):
"""
Create a static offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{id}/grantOffer"
def create_static_offer_from_dynamic_offer(self, request, offer_id, idempotency_key=None, **kwargs):
"""
Create a static offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{offer_id}/grantOffer"

Comment on lines 24 to 28
def get_grant_offer(self, id, idempotency_key=None, **kwargs):
"""
Get the details of a grant offer
Get the details of a static offer
"""
endpoint = self.baseUrl + f"/grantOffers/{id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parameter id shadows the built-in function id(). As per PEP 8, it's best to avoid shadowing built-ins. Please consider renaming it to be more specific, for example, grant_offer_id. I understand this code is auto-generated, but this feedback might be useful for improving the generator.

Suggested change
def get_grant_offer(self, id, idempotency_key=None, **kwargs):
"""
Get the details of a grant offer
Get the details of a static offer
"""
endpoint = self.baseUrl + f"/grantOffers/{id}"
def get_grant_offer(self, grant_offer_id, idempotency_key=None, **kwargs):
"""
Get the details of a static offer
"""
endpoint = self.baseUrl + f"/grantOffers/{grant_offer_id}"

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.

1 participant