Skip to content

Commit 75a976d

Browse files
committed
feature/python-sdk-psd2: Added an internal version of ServiceProviderCredential for PSD2 context.
1 parent 9ad6e10 commit 75a976d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from bunq.sdk.context.api_context import ApiContext
2+
from bunq.sdk.http.api_client import ApiClient
3+
from bunq.sdk.json import converter
4+
from bunq.sdk.model.generated.endpoint import PaymentServiceProviderCredential, UserCredentialPasswordIp
5+
6+
7+
class PaymentServiceProviderCredentialInternal(PaymentServiceProviderCredential):
8+
9+
@classmethod
10+
def create_with_api_context(cls,
11+
client_payment_service_provider_certificate: str,
12+
client_payment_service_provider_certificate_chain: str,
13+
client_public_key_signature: str,
14+
api_context: ApiContext,
15+
all_custom_header=None) -> UserCredentialPasswordIp:
16+
request_map = {
17+
cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE: client_payment_service_provider_certificate,
18+
cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE_CHAIN: client_payment_service_provider_certificate_chain,
19+
cls.FIELD_CLIENT_PUBLIC_KEY_SIGNATURE: client_public_key_signature
20+
}
21+
22+
if all_custom_header is None:
23+
all_custom_header = {}
24+
25+
api_client = ApiClient(api_context)
26+
request_bytes = converter.class_to_json(request_map).encode()
27+
endpoint_url = cls._ENDPOINT_URL_CREATE
28+
response_raw = api_client.post(endpoint_url, request_bytes, all_custom_header)
29+
30+
return UserCredentialPasswordIp.from_json(response_raw.body_bytes.decode())

0 commit comments

Comments
 (0)