Skip to content

Commit 45f58df

Browse files
committed
auto generated management API
1 parent 0012361 commit 45f58df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2296
-2
lines changed

Adyen/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
AdyenRecurring,
2020
AdyenPayment,
2121
AdyenThirdPartyPayout,
22+
AdyenManagementApi,
2223
AdyenCheckoutApi,
2324
AdyenTerminal
2425
)
@@ -35,6 +36,7 @@ def __init__(self, **kwargs):
3536
self.recurring = AdyenRecurring(client=self.client)
3637
self.checkout = AdyenCheckoutApi(client=self.client)
3738
self.terminal = AdyenTerminal(client=self.client)
39+
self.management = AdyenManagementApi(client=self.client)
3840

3941

4042
_base_adyen_obj = Adyen()
@@ -44,3 +46,4 @@ def __init__(self, **kwargs):
4446
checkout = _base_adyen_obj.checkout
4547
binlookup = _base_adyen_obj.binlookup
4648
terminal = _base_adyen_obj.terminal
49+
management = _base_adyen_obj.management

Adyen/client.py

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(
8383
api_bin_lookup_version=None,
8484
api_checkout_utility_version=None,
8585
api_checkout_version=None,
86+
api_management_version=None,
8687
api_payment_version=None,
8788
api_payout_version=None,
8889
api_recurring_version=None,
@@ -109,6 +110,7 @@ def __init__(
109110
self.api_bin_lookup_version = api_bin_lookup_version or settings.API_BIN_LOOKUP_VERSION
110111
self.api_checkout_utility_version = api_checkout_utility_version or settings.API_CHECKOUT_UTILITY_VERSION
111112
self.api_checkout_version = api_checkout_version or settings.API_CHECKOUT_VERSION
113+
self.api_management_version = api_management_version or settings.API_MANAGEMENT_VERSION
112114
self.api_payment_version = api_payment_version or settings.API_PAYMENT_VERSION
113115
self.api_payout_version = api_payout_version or settings.API_PAYOUT_VERSION
114116
self.api_recurring_version = api_recurring_version or settings.API_RECURRING_VERSION
@@ -170,6 +172,15 @@ def _determine_checkout_url(self, platform, endpoint):
170172

171173
return '/'.join([base_uri, api_version, endpoint])
172174

175+
def _determine_management_url(self, platform, endpoint):
176+
api_version = self.api_management_version
177+
if platform == "test":
178+
base_uri = settings.ENDPOINT_MANAGEMENT_TEST
179+
else:
180+
base_uri = settings.ENDPOINT_MANAGEMENT_LIVE
181+
182+
return '/'.join([base_uri, api_version, endpoint])
183+
173184
def _review_payout_username(self, **kwargs):
174185
if 'username' in kwargs:
175186
return kwargs['username']
@@ -452,6 +463,72 @@ def call_checkout_api(self, request_data, method, endpoint, idempotency_key=None
452463

453464
return adyen_result
454465

466+
def call_management_api(self, request_data, method, endpoint, idempotency_key=None,
467+
**kwargs):
468+
"""This will call the checkout adyen api. xapi key merchant_account,
469+
and platform are pulled from root module level and or self object.
470+
AdyenResult will be returned on 200 response. Otherwise, an exception
471+
is raised.
472+
473+
Args:
474+
idempotency_key: https://docs.adyen.com/development-resources
475+
/api-idempotency
476+
request_data (dict): The dictionary of the request to place. This
477+
should be in the structure of the Adyen API.
478+
https://docs.adyen.com/api-explorer/#/CheckoutService
479+
method (str): This is the method used to send the request to an endpoint.
480+
endpoint (str): The specific endpoint of the API service to be called
481+
"""
482+
if not self.http_init:
483+
self._init_http_client()
484+
485+
# xapi at self object has highest priority. fallback to root module
486+
# and ensure that it is set.
487+
xapikey = False
488+
if self.xapikey:
489+
xapikey = self.xapikey
490+
elif 'xapikey' in kwargs:
491+
xapikey = kwargs.pop("xapikey")
492+
493+
if not xapikey:
494+
errorstring = """Please set your webservice xapikey.
495+
You can do this by running 'Adyen.xapikey = 'Your xapikey'"""
496+
raise AdyenInvalidRequestError(errorstring)
497+
498+
# platform at self object has highest priority. fallback to root module
499+
# and ensure that it is set to either 'live' or 'test'.
500+
platform = None
501+
if self.platform:
502+
platform = self.platform
503+
elif 'platform' in kwargs:
504+
platform = kwargs.pop('platform')
505+
506+
if not isinstance(platform, str):
507+
errorstring = "'platform' value must be type of string"
508+
raise TypeError(errorstring)
509+
elif platform.lower() not in ['live', 'test']:
510+
errorstring = "'platform' must be the value of 'live' or 'test'"
511+
raise ValueError(errorstring)
512+
513+
# Adyen requires this header to be set and uses the combination of
514+
# merchant account and merchant reference to determine uniqueness.
515+
headers = {}
516+
if idempotency_key:
517+
headers[self.IDEMPOTENCY_HEADER_NAME] = idempotency_key
518+
url = self._determine_management_url(platform, endpoint)
519+
520+
raw_response, raw_request, status_code, headers = \
521+
self.http_client.request(method, url, json=request_data,
522+
xapikey=xapikey, headers=headers,
523+
**kwargs)
524+
525+
# Creates AdyenResponse if request was successful, raises error if not.
526+
adyen_result = self._handle_response(url, raw_response, raw_request,
527+
status_code, headers,
528+
request_data)
529+
530+
return adyen_result
531+
455532
def _handle_response(self, url, raw_response, raw_request,
456533
status_code, headers, request_dict):
457534
"""This parses the content from raw communication, raising an error if
@@ -469,7 +546,8 @@ def _handle_response(self, url, raw_response, raw_request,
469546
Returns:
470547
AdyenResult: Result object if successful.
471548
"""
472-
if status_code != 200 and status_code != 201:
549+
550+
if status_code != 200 and status_code != 201 and status_code != 204:
473551
response = {}
474552
# If the result can't be parsed into json, most likely is raw html.
475553
# Some response are neither json or raw html, handle them here:
@@ -502,7 +580,10 @@ def _handle_response(self, url, raw_response, raw_request,
502580
erstr = 'KeyError: errorCode'
503581
raise AdyenAPICommunicationError(erstr)
504582
else:
505-
response = json_lib.loads(raw_response)
583+
if status_code != 204:
584+
response = json_lib.loads(raw_response)
585+
else:
586+
response = {}
506587
psp = self._get_psp(response, headers)
507588
return AdyenResult(message=response, status_code=status_code,
508589
psp=psp, raw_request=raw_request,

Adyen/services/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
from .payouts import AdyenThirdPartyPayout
66
from .recurring import AdyenRecurring
77
from .terminal import AdyenTerminal
8+
from .management import AdyenManagementApi

Adyen/services/management.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""
2+
Management API
3+
4+
Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. ## Authentication Each request to the Management API must be signed with an API key. [Generate your API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key) in the Customer Area and then set this key to the `X-API-Key` header value. To access the live endpoints, you need to generate a new API key in your live Customer Area. ## Versioning Management API handles versioning as part of the endpoint URL. For example, to send a request to version 1 of the `/companies/{companyId}/webhooks` endpoint, use: ```text https://management-test.adyen.com/v1/companies/{companyId}/webhooks ``` ## Going live To access the live endpoints, you need an API key from your live Customer Area. Use this API key to make requests to: ```text https://management-live.adyen.com/v1 ``` # noqa: E501
5+
6+
The version of the OpenAPI document: 1
7+
Contact: developer-experience@adyen.com
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
from .base import AdyenServiceBase
12+
from .management_dir.api_credentials_company_level_api import APICredentialsCompanyLevelApi
13+
from .management_dir.api_credentials_merchant_level_api import APICredentialsMerchantLevelApi
14+
from .management_dir.api_key_company_level_api import APIKeyCompanyLevelApi
15+
from .management_dir.api_key_merchant_level_api import APIKeyMerchantLevelApi
16+
from .management_dir.account_company_level_api import AccountCompanyLevelApi
17+
from .management_dir.account_merchant_level_api import AccountMerchantLevelApi
18+
from .management_dir.account_store_level_api import AccountStoreLevelApi
19+
from .management_dir.allowed_origins_company_level_api import AllowedOriginsCompanyLevelApi
20+
from .management_dir.allowed_origins_merchant_level_api import AllowedOriginsMerchantLevelApi
21+
from .management_dir.client_key_company_level_api import ClientKeyCompanyLevelApi
22+
from .management_dir.client_key_merchant_level_api import ClientKeyMerchantLevelApi
23+
from .management_dir.my_api_credential_api import MyAPICredentialApi
24+
from .management_dir.payment_methods_merchant_level_api import PaymentMethodsMerchantLevelApi
25+
from .management_dir.payout_settings_merchant_level_api import PayoutSettingsMerchantLevelApi
26+
from .management_dir.terminal_actions_company_level_api import TerminalActionsCompanyLevelApi
27+
from .management_dir.terminal_actions_terminal_level_api import TerminalActionsTerminalLevelApi
28+
from .management_dir.terminal_orders_company_level_api import TerminalOrdersCompanyLevelApi
29+
from .management_dir.terminal_orders_merchant_level_api import TerminalOrdersMerchantLevelApi
30+
from .management_dir.terminal_settings_company_level_api import TerminalSettingsCompanyLevelApi
31+
from .management_dir.terminal_settings_merchant_level_api import TerminalSettingsMerchantLevelApi
32+
from .management_dir.terminal_settings_store_level_api import TerminalSettingsStoreLevelApi
33+
from .management_dir.terminal_settings_terminal_level_api import TerminalSettingsTerminalLevelApi
34+
from .management_dir.terminals_terminal_level_api import TerminalsTerminalLevelApi
35+
from .management_dir.users_company_level_api import UsersCompanyLevelApi
36+
from .management_dir.users_merchant_level_api import UsersMerchantLevelApi
37+
from .management_dir.webhooks_company_level_api import WebhooksCompanyLevelApi
38+
from .management_dir.webhooks_merchant_level_api import WebhooksMerchantLevelApi
39+
40+
41+
class AdyenManagementApi(AdyenServiceBase):
42+
"""NOTE: This class is auto generated by OpenAPI Generator
43+
Ref: https://openapi-generator.tech
44+
45+
Do not edit the class manually.
46+
"""
47+
48+
def __init__(self, client=None):
49+
super(AdyenManagementApi, self).__init__(client=client)
50+
self.api_credentials_company_level_api = APICredentialsCompanyLevelApi(client=client)
51+
self.api_credentials_merchant_level_api = APICredentialsMerchantLevelApi(client=client)
52+
self.api_key_company_level_api = APIKeyCompanyLevelApi(client=client)
53+
self.api_key_merchant_level_api = APIKeyMerchantLevelApi(client=client)
54+
self.account_company_level_api = AccountCompanyLevelApi(client=client)
55+
self.account_merchant_level_api = AccountMerchantLevelApi(client=client)
56+
self.account_store_level_api = AccountStoreLevelApi(client=client)
57+
self.allowed_origins_company_level_api = AllowedOriginsCompanyLevelApi(client=client)
58+
self.allowed_origins_merchant_level_api = AllowedOriginsMerchantLevelApi(client=client)
59+
self.client_key_company_level_api = ClientKeyCompanyLevelApi(client=client)
60+
self.client_key_merchant_level_api = ClientKeyMerchantLevelApi(client=client)
61+
self.my_api_credential_api = MyAPICredentialApi(client=client)
62+
self.payment_methods_merchant_level_api = PaymentMethodsMerchantLevelApi(client=client)
63+
self.payout_settings_merchant_level_api = PayoutSettingsMerchantLevelApi(client=client)
64+
self.terminal_actions_company_level_api = TerminalActionsCompanyLevelApi(client=client)
65+
self.terminal_actions_terminal_level_api = TerminalActionsTerminalLevelApi(client=client)
66+
self.terminal_orders_company_level_api = TerminalOrdersCompanyLevelApi(client=client)
67+
self.terminal_orders_merchant_level_api = TerminalOrdersMerchantLevelApi(client=client)
68+
self.terminal_settings_company_level_api = TerminalSettingsCompanyLevelApi(client=client)
69+
self.terminal_settings_merchant_level_api = TerminalSettingsMerchantLevelApi(client=client)
70+
self.terminal_settings_store_level_api = TerminalSettingsStoreLevelApi(client=client)
71+
self.terminal_settings_terminal_level_api = TerminalSettingsTerminalLevelApi(client=client)
72+
self.terminals_terminal_level_api = TerminalsTerminalLevelApi(client=client)
73+
self.users_company_level_api = UsersCompanyLevelApi(client=client)
74+
self.users_merchant_level_api = UsersMerchantLevelApi(client=client)
75+
self.webhooks_company_level_api = WebhooksCompanyLevelApi(client=client)
76+
self.webhooks_merchant_level_api = WebhooksMerchantLevelApi(client=client)

Adyen/services/management_dir/__init__.py

Whitespace-only changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Management API
3+
4+
Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. ## Authentication Each request to the Management API must be signed with an API key. [Generate your API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key) in the Customer Area and then set this key to the `X-API-Key` header value. To access the live endpoints, you need to generate a new API key in your live Customer Area. ## Versioning Management API handles versioning as part of the endpoint URL. For example, to send a request to version 1 of the `/companies/{companyId}/webhooks` endpoint, use: ```text https://management-test.adyen.com/v1/companies/{companyId}/webhooks ``` ## Going live To access the live endpoints, you need an API key from your live Customer Area. Use this API key to make requests to: ```text https://management-live.adyen.com/v1 ``` # noqa: E501
5+
6+
The version of the OpenAPI document: 1
7+
Contact: developer-experience@adyen.com
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
from ..base import AdyenServiceBase
12+
13+
14+
class AccountCompanyLevelApi(AdyenServiceBase):
15+
"""NOTE: This class is auto generated by OpenAPI Generator
16+
Ref: https://openapi-generator.tech
17+
18+
Do not edit the class manually.
19+
"""
20+
21+
def __init__(self, client=None):
22+
super(AccountCompanyLevelApi, self).__init__(client=client)
23+
self.service = "management"
24+
25+
def get_companies(self, idempotency_key=None, **kwargs):
26+
"""
27+
Get a list of company accounts
28+
"""
29+
endpoint = f"/companies"
30+
endpoint = endpoint.replace('/','',1)
31+
method = "GET"
32+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
33+
34+
def get_companies_company_id(self, companyId, idempotency_key=None, **kwargs):
35+
"""
36+
Get a company account
37+
"""
38+
endpoint = f"/companies/{companyId}"
39+
endpoint = endpoint.replace('/','',1)
40+
method = "GET"
41+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
42+
43+
def get_companies_company_id_merchants(self, companyId, idempotency_key=None, **kwargs):
44+
"""
45+
Get a list of merchant accounts
46+
"""
47+
endpoint = f"/companies/{companyId}/merchants"
48+
endpoint = endpoint.replace('/','',1)
49+
method = "GET"
50+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
51+
52+
53+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Management API
3+
4+
Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. ## Authentication Each request to the Management API must be signed with an API key. [Generate your API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key) in the Customer Area and then set this key to the `X-API-Key` header value. To access the live endpoints, you need to generate a new API key in your live Customer Area. ## Versioning Management API handles versioning as part of the endpoint URL. For example, to send a request to version 1 of the `/companies/{companyId}/webhooks` endpoint, use: ```text https://management-test.adyen.com/v1/companies/{companyId}/webhooks ``` ## Going live To access the live endpoints, you need an API key from your live Customer Area. Use this API key to make requests to: ```text https://management-live.adyen.com/v1 ``` # noqa: E501
5+
6+
The version of the OpenAPI document: 1
7+
Contact: developer-experience@adyen.com
8+
Generated by: https://openapi-generator.tech
9+
"""
10+
11+
from ..base import AdyenServiceBase
12+
13+
14+
class AccountMerchantLevelApi(AdyenServiceBase):
15+
"""NOTE: This class is auto generated by OpenAPI Generator
16+
Ref: https://openapi-generator.tech
17+
18+
Do not edit the class manually.
19+
"""
20+
21+
def __init__(self, client=None):
22+
super(AccountMerchantLevelApi, self).__init__(client=client)
23+
self.service = "management"
24+
25+
def get_merchants(self, idempotency_key=None, **kwargs):
26+
"""
27+
Get a list of merchant accounts
28+
"""
29+
endpoint = f"/merchants"
30+
endpoint = endpoint.replace('/','',1)
31+
method = "GET"
32+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
33+
34+
def get_merchants_merchant_id(self, merchantId, idempotency_key=None, **kwargs):
35+
"""
36+
Get a merchant account
37+
"""
38+
endpoint = f"/merchants/{merchantId}"
39+
endpoint = endpoint.replace('/','',1)
40+
method = "GET"
41+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
42+
43+
def post_merchants(self, request, idempotency_key=None, **kwargs):
44+
"""
45+
Create a merchant account
46+
"""
47+
endpoint = f"/merchants"
48+
endpoint = endpoint.replace('/','',1)
49+
method = "POST"
50+
return self.client.call_management_api(request, method, endpoint, idempotency_key, **kwargs)
51+
52+
def post_merchants_merchant_id_activate(self, merchantId, idempotency_key=None, **kwargs):
53+
"""
54+
Request to activate a merchant account
55+
"""
56+
endpoint = f"/merchants/{merchantId}/activate"
57+
endpoint = endpoint.replace('/','',1)
58+
method = "POST"
59+
return self.client.call_management_api(None, method, endpoint, idempotency_key, **kwargs)
60+
61+
62+

0 commit comments

Comments
 (0)