# -*- 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

class ValidationController(BaseController):

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


    def get_booking_pal_validationjob_full_pm(self):
        """Does a GET request to /validation.

        This function will allow the PMC to call the BookingPal property
        validation job for all properties identified which belong to the
        current user. Authorization token should be on PM level. 
        Also we will run validation only for properties which are activated.
        If you deactivate property - we will not validate this property.
        After the request you will get a response indicating if messages were
        processed or not. If the request is good your request for the
        validator job will be put into a queue. Once the request is processed,
        BookingPal will send an async push message per property informing the
        user if a property is valid or not, and if it is not valid - with
        reasons why the validation failed. This message will be sent on the
        endpoint which was entered in section Push Notifications, field
        asyncPush.
        Note: If the property is distributed already on some channel - this
        property will not be moved to an Incomplete state. Also if you have
        property on Incomplete state because of some reason, and you update
        this data which causes that property is on ‘Incomplete’ property will
        not be moved automatically to a valid state. Instead, you should run a
        Validation job manually for that property or wait for our automatic
        validation job which we are running once per day. 
        To make the property ready for Onboarding you should run validation
        first. if the property is valid - it will be ready for onboarding.
        Otherwise - the property will be in Incomplete state. Also, we will
        run validation only for properties that are activated. If you
        deactivate property - we will not validate this property.

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

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

        This function will allow the PMS to call the BookingPal property
        validation job for a list of properties from request. These properties
        must belong to the current user and authorization token should be on
        PM level.
        Also, we will run validation only for properties that are activated.
        If you deactivate property - we will not validate this property.

        Args:
            content_type (string): TODO: type description here. Example: 
            body (ValidationforListofpropertiesRequest): 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 = '/validation'
        _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)
