# -*- coding: utf-8 -*-

"""
    apimaticcalculatorlatest

    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""

from apimaticcalculatorlatest.api_helper import APIHelper
from apimaticcalculatorlatest.configuration import Configuration
from apimaticcalculatorlatest.controllers.base_controller import BaseController
from apimaticcalculatorlatest.http.auth.custom_query_auth import CustomQueryAuth
from apimaticcalculatorlatest.models.fee_tax_response import FeeTaxResponse

class FeeAndTaxController(BaseController):

    """A Controller to access Endpoints in the apimaticcalculatorlatest API."""


    def getfeeandtaxlistbyproduct_id(self,
                                     product_id):
        """Does a GET request to /taxfee/{productId}.

        This function allows the logged in user to get a fee list for the
        specific product.

        Args:
            product_id (string): ID of the property

        Returns:
            FeeTaxResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/taxfee/{productId}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'productId': product_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        CustomQueryAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, FeeTaxResponse.from_dictionary)

    def createfeeandtax(self,
                        content_type,
                        body):
        """Does a POST request to /taxfee.

        This function allows the logged in user to set fees (i.e. cleaning
        fee, damage waiver, extra bed, extra person etc.) and taxes for the
        specific product. Here, you always need to send all fees and taxes for
        one property. All fees or taxes which were in our system for that
        property and which are not in the new request will be deleted. Taxes
        in the BookingPal system will always have percent value. 
        If you want to delete all fees and/or taxes for one property (if you
        do not have fees and taxes in your system for one property) send an
        empty list of fees and.or taxes. In short when you use this request
        you need to always send us a full list of fees and taxes per property,
        since we will do a full update.

        Args:
            content_type (string): TODO: type description here. Example: 
            body (CreatefeeandtaxRequest): TODO: type description here.
                Example: 

        Returns:
            FeeTaxResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/taxfee'
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'Content-Type': content_type
        }

        # Prepare and execute request
        _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
        CustomQueryAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, FeeTaxResponse.from_dictionary)
