Skip to content
Open
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)
39 changes: 39 additions & 0 deletions Adyen/services/capital/dynamic_offers_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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"
Comment on lines +16 to +20
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"

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 +24 to +28
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 + f"/dynamicOffers"

Check warning on line 36 in Adyen/services/capital/dynamic_offers_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02gr63pryTICbQD-&open=AZ0K02gr63pryTICbQD-&pullRequest=454
method = "GET"
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

5 changes: 2 additions & 3 deletions Adyen/services/capital/grant_accounts_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ def get_grant_account_information(self, id, idempotency_key=None, **kwargs):
"""
endpoint = self.baseUrl + f"/grantAccounts/{id}"
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

15 changes: 6 additions & 9 deletions Adyen/services/capital/grant_offers_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@

def get_all_grant_offers(self, idempotency_key=None, **kwargs):
"""
Get all available grant offers
Get all available static offers
"""
endpoint = self.baseUrl + "/grantOffers"
endpoint = self.baseUrl + f"/grantOffers"

Check warning on line 20 in Adyen/services/capital/grant_offers_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02fc63pryTICbQD5&open=AZ0K02fc63pryTICbQD5&pullRequest=454
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **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 24 to 28
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"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

33 changes: 10 additions & 23 deletions Adyen/services/capital/grants_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,45 @@
"""
endpoint = self.baseUrl + f"/grants/{grantId}/disbursements"
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def get_all_grants(self, idempotency_key=None, **kwargs):
"""
Get all the grants of an account holder
"""
endpoint = self.baseUrl + "/grants"
endpoint = self.baseUrl + f"/grants"

Check warning on line 28 in Adyen/services/capital/grants_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02gX63pryTICbQD6&open=AZ0K02gX63pryTICbQD6&pullRequest=454
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def get_grant(self, grantId, idempotency_key=None, **kwargs):
"""
Get the details of a grant
"""
endpoint = self.baseUrl + f"/grants/{grantId}"
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def get_grant_disbursement(self, grantId, disbursementId, idempotency_key=None, **kwargs):
"""
Get disbursement details
"""
endpoint = self.baseUrl + f"/grants/{grantId}/disbursements/{disbursementId}"
method = "GET"
return self.client.call_adyen_api(
None, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def request_grant(self, request, idempotency_key=None, **kwargs):
"""
Make a request for a grant
"""
endpoint = self.baseUrl + "/grants"
endpoint = self.baseUrl + f"/grants"

Check warning on line 52 in Adyen/services/capital/grants_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02gX63pryTICbQD7&open=AZ0K02gX63pryTICbQD7&pullRequest=454
method = "POST"
return self.client.call_adyen_api(
request, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)

def update_grant_disbursement(
self, request, grantId, disbursementId, idempotency_key=None, **kwargs
):
def update_grant_disbursement(self, request, grantId, disbursementId, idempotency_key=None, **kwargs):

Check warning on line 56 in Adyen/services/capital/grants_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter "disbursementId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02gX63pryTICbQD8&open=AZ0K02gX63pryTICbQD8&pullRequest=454

Check warning on line 56 in Adyen/services/capital/grants_api.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this parameter "grantId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-python-api-library&issues=AZ0K02gX63pryTICbQD9&open=AZ0K02gX63pryTICbQD9&pullRequest=454
"""
Update the repayment configuration of a disbursement
"""
endpoint = self.baseUrl + f"/grants/{grantId}/disbursements/{disbursementId}"
method = "PATCH"
return self.client.call_adyen_api(
request, self.service, method, endpoint, idempotency_key, **kwargs
)
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)

Loading