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