from ..base import AdyenServiceBase


class DynamicOffersApi(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 calculate_preliminary_offer_from_dynamic_offer(
        self, request, id, idempotency_key=None, **kwargs
    ):
        """
        Calculate a preliminary offer for a selected financing amount
        """
        endpoint = self.baseUrl + f"/dynamicOffers/{id}/calculate"
        method = "POST"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def create_static_offer_from_dynamic_offer(self, request, id, idempotency_key=None, **kwargs):
        """
        Create a static offer for a selected financing amount
        """
        endpoint = self.baseUrl + f"/dynamicOffers/{id}/grantOffer"
        method = "POST"
        return self.client.call_adyen_api(
            request, self.service, method, endpoint, idempotency_key, **kwargs
        )

    def get_all_dynamic_offers(self, idempotency_key=None, **kwargs):
        """
        Get all available dynamic offers
        """
        endpoint = self.baseUrl + "/dynamicOffers"
        method = "GET"
        return self.client.call_adyen_api(
            None, self.service, method, endpoint, idempotency_key, **kwargs
        )
