Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Adyen/services/capital/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..base import AdyenServiceBase
from .dynamic_offers_api import DynamicOffersApi
from .grant_accounts_api import GrantAccountsApi
from .grant_offers_api import GrantOffersApi
from .grants_api import GrantsApi
Expand All @@ -13,6 +14,7 @@ class AdyenCapitalApi(AdyenServiceBase):

def __init__(self, client=None):
super().__init__(client=client)
self.dynamic_offers_api = DynamicOffersApi(client=client)
self.grant_accounts_api = GrantAccountsApi(client=client)
self.grant_offers_api = GrantOffersApi(client=client)
self.grants_api = GrantsApi(client=client)
46 changes: 46 additions & 0 deletions Adyen/services/capital/dynamic_offers_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from ..base import AdyenServiceBase


class DynamicOffersApi(AdyenServiceBase):
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech

Do not edit the class manually.
"""

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.


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"
method = "POST"
return self.client.call_adyen_api(
request, self.service, method, endpoint, idempotency_key, **kwargs
)

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"
Comment on lines +28 to +32
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"

method = "POST"
return self.client.call_adyen_api(
request, self.service, method, endpoint, idempotency_key, **kwargs
)

def get_all_dynamic_offers(self, idempotency_key=None, **kwargs):
"""
Get all available dynamic offers
"""
endpoint = self.baseUrl + "/dynamicOffers"
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
4 changes: 2 additions & 2 deletions Adyen/services/capital/grant_offers_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, client=None):

def get_all_grant_offers(self, idempotency_key=None, **kwargs):
"""
Get all available grant offers
Get all available static offers
"""
endpoint = self.baseUrl + "/grantOffers"
method = "GET"
Expand All @@ -25,7 +25,7 @@ def get_all_grant_offers(self, idempotency_key=None, **kwargs):

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}"
Comment on lines 26 to 30
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}"

method = "GET"
Expand Down
Loading