Skip to content
Merged
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"
Comment on lines +13 to +14
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 service and baseUrl attributes are hardcoded and duplicated across all API classes in the capital service (DynamicOffersApi, GrantAccountsApi, GrantOffersApi, GrantsApi). This violates the DRY (Don't Repeat Yourself) principle and makes maintenance harder. To improve maintainability, consider defining these in a shared base class for all capital services or as constants in a shared module.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good feedback, but not in scope of this PR as it's generated code. We can create a follow-up ticket internally


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"
Comment on lines +17 to +22
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 name id shadows the built-in Python function id(). According to the PEP 8 style guide, it is recommended to use a trailing underscore like id_ to avoid such conflicts.

Suggested change
self, request, id, idempotency_key=None, **kwargs
):
"""
Calculate a preliminary offer for a selected financing amount
"""
endpoint = self.baseUrl + f"/dynamicOffers/{id}/calculate"
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.

Good feedback, but not in socpe as this is generated code

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 name id shadows the built-in Python function id(). According to the PEP 8 style guide, it is recommended to use a trailing underscore like id_ to avoid such conflicts.

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

Good feedback, but not in scope as generated code

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}"
method = "GET"
Expand Down
Loading