# -*- 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.lo_sratesresponse import LOSratesresponse

class LOSPricingController(BaseController):

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


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

        Introduction: You can use this function if you would like to send
        BookingPal different prices for various Length of Stays with the same
        starting date.
        LOS Pricing will be a different method in sending rates to BookingPal
        and is defined as pricing sent for a specific “Stay ranges”, In the
        LOS  method you are setting specific rates based on the Length of
        Stay. (This is a different way to push rates to BookingPal. )
        For date periods of 1 to 30 days a specific rate need to enter
        check-in date and a rate for every possible reservation starting at
        that date (i.e. 1 day, 2 days, up to 30 days, 30 days is the maximum
        value allowed for this field) you will need to send BookingPal total
        rate value for that period. 
        Maximum LOS number of days is 30. All other LOS values after 30 will
        not be saved. If you do not support reservation for some specific
        number of dates - send value 0.00 for this LOS number of days. Keep in
        mind that all values not sent for any specific check-in date will be
        considered as 0, and reservation for this number of days will not be
        possible.
        Field maxGuests allows you to set different rates per different number
        of guests. If you do not have different rate values per number of
        guests - you can send the value for maximum number of guests, and all
        others will have the same rate.
        For MLT properties which supported LOS price for update number of
        count you can use it rates and availability API.
        It is suggested to manage availability over “rates and availability”
        API call, and to close/open dates over this call.
        Note: this API call can be used only if you set supportedLosRates =
        true on the product. Otherwise using this API for specific product is
        not possible.

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

        Returns:
            LOSratesresponse: 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 = '/losrates'
        _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, LOSratesresponse.from_dictionary)

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

        This function allows the logged in user to get a LOS rate for
        property.

        Args:
            product_id (string): Property ID in BookingPal

        Returns:
            LOSratesresponse: 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 = '/losrates/{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, LOSratesresponse.from_dictionary)
