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
5 changes: 4 additions & 1 deletion Adyen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
AdyenDataProtectionApi,
AdyenTransfersApi,
AdyenStoredValueApi,
AdyenBalancePlatformApi
AdyenBalancePlatformApi,
AdyenCapitalApi
)

from .httpclient import HTTPClient
Expand All @@ -47,6 +48,7 @@ def __init__(self, **kwargs):
self.transfers = AdyenTransfersApi(client=self.client)
self.storedValue = AdyenStoredValueApi(client=self.client)
self.balancePlatform = AdyenBalancePlatformApi(client=self.client)
self.capital = AdyenCapitalApi(client=self.client)


_base_adyen_obj = Adyen()
Expand All @@ -62,3 +64,4 @@ def __init__(self, **kwargs):
transfers = _base_adyen_obj.transfers
storedValue = _base_adyen_obj.storedValue
balancePlatform = _base_adyen_obj.balancePlatform
capital = _base_adyen_obj.capital
15 changes: 12 additions & 3 deletions Adyen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def __init__(
api_data_protection_version=None,
api_transfers_version=None,
api_stored_value_version=None,
api_balance_platform_version=None
api_balance_platform_version=None,
api_capital_version=None
):
self.username = username
self.password = password
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(
self.api_transfers_version = api_transfers_version or settings.API_TRANSFERS_VERSION
self.api_stored_value_version = api_stored_value_version or settings.API_STORED_VALUE_VERSION
self.api_balance_platform_version = api_balance_platform_version or settings.API_BALANCE_PLATFORM_VERSION
self.api_capital_version = api_capital_version or settings.API_CAPITAL_VERSION

def _determine_base_url_and_version(self, platform, service):

Expand Down Expand Up @@ -212,8 +214,8 @@ def _determine_base_url_and_version(self, platform, service):
'transfers': {
'version': self.api_transfers_version,
'base_url': {
'live': settings.BASE_TRANSFERS_URL.format(platform),
'test': settings.BASE_TRANSFERS_URL.format(platform)
'live': settings.BASE_BTL_URL.format(platform),
'test': settings.BASE_BTL_URL.format(platform)
}
},
'storedValue': {
Expand All @@ -222,6 +224,13 @@ def _determine_base_url_and_version(self, platform, service):
'live': settings.BASE_STORED_VALUE_URL.format(platform),
'test': settings.BASE_STORED_VALUE_URL.format(platform)
}
},
'capital': {
'version': self.api_capital_version,
'base_url': {
'live': settings.BASE_BTL_URL.format(platform),
'test': settings.BASE_BTL_URL.format(platform)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Adyen/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from .transfers import AdyenTransfersApi
from .storedValue import AdyenStoredValueApi
from .balancePlatform import AdyenBalancePlatformApi
from .capital import AdyenCapitalApi
38 changes: 38 additions & 0 deletions Adyen/services/capital.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from .base import AdyenServiceBase


class AdyenCapitalApi(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(AdyenCapitalApi, self).__init__(client=client)
self.service = "capital"

def get_capital_account(self, idempotency_key=None, **kwargs):
"""
Get a capital account
"""
endpoint = f"/grants"
method = "GET"
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def get_grant_reference_details(self, id, idempotency_key=None, **kwargs):
"""
Get grant reference details
"""
endpoint = f"/grants/{id}"
method = "GET"
return self.client.call_adyen_api(None, self.service, method, endpoint, idempotency_key, **kwargs)

def request_grant_payout(self, request, idempotency_key=None, **kwargs):
"""
Request a grant payout
"""
endpoint = f"/grants"
method = "POST"
return self.client.call_adyen_api(request, self.service, method, endpoint, idempotency_key, **kwargs)

3 changes: 2 additions & 1 deletion Adyen/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Those constants are used from the library only
BASE_DATA_PROTECION_URL = "https://ca-{}.adyen.com/ca/services/DataProtectionService"
BASE_CONFIGURATION_URL = "https://balanceplatform-api-{}.adyen.com/bcl"
BASE_BTL_URL = "https://balanceplatform-api-{}.adyen.com/btl"
BASE_TERMINAL_URL = "https://postfmapi-{}.adyen.com/postfmapi/terminal"
BASE_TRANSFERS_URL = "https://balanceplatform-api-{}.adyen.com/btl"
BASE_MANAGEMENT_URL = "https://management-{}.adyen.com"
BASE_LEGAL_ENTITY_MANAGEMENT_URL = "https://kyc-{}.adyen.com/lem"
PAL_LIVE_ENDPOINT_URL_TEMPLATE = "https://{live_prefix}-pal-live" \
Expand All @@ -13,6 +13,7 @@
".adyenpayments.com/checkout"
BASE_STORED_VALUE_URL = "https://pal-{}.adyen.com/pal/servlet/StoredValue"
API_BALANCE_PLATFORM_VERSION = "v2"
API_CAPITAL_VERSION = "v3"
API_BIN_LOOKUP_VERSION = "v52"
API_CHECKOUT_VERSION = "v70"
API_CHECKOUT_UTILITY_VERSION = "v1"
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ openapi-generator-jar:=build/openapi-generator-cli.jar
openapi-generator-cli:=java -jar $(openapi-generator-jar)
output:=build/out
services:=balancePlatform checkout legalEntityManagement management payments payouts platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration transfers
smallServices:=balanceControlService binlookup dataProtection recurring storedValue terminal
smallServices:=balanceControlService binlookup dataProtection recurring storedValue terminal capital

all: $(services) $(smallServices)

Expand All @@ -36,6 +36,7 @@ platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
platformsHostedOnboardingPage: spec=HopService-v6
transfers: spec=TransferService-v3
balanceControlService: spec=BalanceControlService-v1
capital: spec=GrantService-v3

$(services): build/spec $(openapi-generator-jar)
rm -rf Adyen/services/$@ $(output)
Expand Down Expand Up @@ -64,7 +65,7 @@ $(smallServices): build/spec $(openapi-generator-jar)
--additional-properties serviceName=$@\
--skip-validate-spec
mkdir -p Adyen/services
cp $(output)/openapi_client/api/general_api-small.py Adyen/services/$@.py
cp $(output)/openapi_client/api/*-small.py Adyen/services/$@.py



Expand Down
30 changes: 30 additions & 0 deletions test/ClientTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Adyen
import unittest
from Adyen import settings

try:
from BaseTest import BaseTest
except ImportError:
from .BaseTest import BaseTest


class TestClient(unittest.TestCase):
adyen = Adyen.Adyen()

client = adyen.client
test = BaseTest(adyen)
client.xapikey = "YourXapikey"
client.platform = "test"
lib_version = settings.LIB_VERSION

def test_url_creation_for_capitalAPI(self):
self.adyen.client = self.test.create_client_from_file(200, {}, "test/mocks/"
"generic_response.json")
self.adyen.capital.get_capital_account()
self.adyen.client.http_client.request.assert_called_once_with(
'GET',
'https://balanceplatform-api-test.adyen.com/btl/{}/grants'.format(settings.API_CAPITAL_VERSION),
headers={'adyen-library-name': 'adyen-python-api-library', 'adyen-library-version': settings.LIB_VERSION},
json=None,
xapikey='YourXapikey'
)
3 changes: 3 additions & 0 deletions test/mocks/generic_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}