from ..base import AdyenServiceBase


class APICredentialsMerchantLevelApi(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 = "management"
        self.baseUrl = "https://management-test.adyen.com/v3"

    def create_api_credential(self, request, merchantId, idempotency_key=None, **kwargs):
        """
        Create an API credential
        """
        endpoint = self.baseUrl + f"/merchants/{merchantId}/apiCredentials"
        method = "POST"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def get_api_credential(self, merchantId, apiCredentialId, idempotency_key=None, **kwargs):
        """
        Get an API credential
        """
        endpoint = self.baseUrl + f"/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def list_api_credentials(self, merchantId, idempotency_key=None, **kwargs):
        """
        Get a list of API credentials
        """
        endpoint = self.baseUrl + f"/merchants/{merchantId}/apiCredentials"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def update_api_credential(
        self, request, merchantId, apiCredentialId, idempotency_key=None, **kwargs
    ):
        """
        Update an API credential
        """
        endpoint = self.baseUrl + f"/merchants/{merchantId}/apiCredentials/{apiCredentialId}"
        method = "PATCH"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )
