# -*- 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.api_responsewithout_data import APIResponsewithoutData
from apimaticcalculatorlatest.models.reservationpush_response import ReservationpushResponse

class RequestToBookController(BaseController):

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


    def create_requestto_book_test(self,
                                   body):
        """Does a POST request to /requestToBookTest.

        Since you can not get the request to book on our test environment
        (since this first needs to be created on the channel) We provide the
        possibility for PMS to test this request with some random filled data
        in our system. So when you call this API function - we will send you
        push notification for the request to book for a provided property ID.

        Args:
            body (RequesttoBookTestRequest): TODO: type description here.
                Example: 

        Returns:
            APIResponsewithoutData: 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 = '/requestToBookTest'
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8'
        }

        # 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, APIResponsewithoutData.from_dictionary)

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

        This is an API call which you should use for accepting on avoiding
        requests to book.

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

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

    def create_requestto_book_request(self,
                                      body):
        """Does a POST request to /.

        This will be a request which we will send to PMS when we get a request
        to book from the channel.
        So when BookingPal gets a new request to book request - we will push
        this POST request to the link which you set in BookingPal for your PMS
        (in Push Notification section - "requestToBook"). 
        Important note: In this doc to be able to test this - you need to set
        a full URL on the Configure button in the right section.

        Args:
            body (RequestToBookRequestModel): TODO: type description here.
                Example: 

        Returns:
            ReservationpushResponse: 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 = '/'
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8'
        }

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

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