from ..base import AdyenServiceBase


class GrantsApi(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 = "capital"
        self.baseUrl = "https://balanceplatform-api-test.adyen.com/capital/v1"

    def get_all_grant_disbursements(self, grantId, idempotency_key=None, **kwargs):
        """
        Get all the disbursements of a grant
        """
        endpoint = self.baseUrl + f"/grants/{grantId}/disbursements"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def get_all_grants(self, idempotency_key=None, **kwargs):
        """
        Get all the grants of an account holder
        """
        endpoint = self.baseUrl + "/grants"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def get_grant(self, grantId, idempotency_key=None, **kwargs):
        """
        Get the details of a grant
        """
        endpoint = self.baseUrl + f"/grants/{grantId}"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def get_grant_disbursement(self, grantId, disbursementId, idempotency_key=None, **kwargs):
        """
        Get disbursement details
        """
        endpoint = self.baseUrl + f"/grants/{grantId}/disbursements/{disbursementId}"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def request_grant(self, request, idempotency_key=None, **kwargs):
        """
        Make a request for a grant
        """
        endpoint = self.baseUrl + "/grants"
        method = "POST"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def update_grant_disbursement(
        self, request, grantId, disbursementId, idempotency_key=None, **kwargs
    ):
        """
        Update the repayment configuration of a disbursement
        """
        endpoint = self.baseUrl + f"/grants/{grantId}/disbursements/{disbursementId}"
        method = "PATCH"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )
