# -*- 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.get_p_mslist import GetPMslist
from apimaticcalculatorlatest.models.property_managerdetailsresponse import PropertyManagerdetailsresponse

class PropertyManagersController(BaseController):

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


    def get_p_mslist(self):
        """Does a GET request to /pmlist.

        This API call will return a list of property managers (PM) that have
        been created in the BookingPal platform that is associated with your
        PMS.
        In all requests in this API section, you need to use your PMS
        credentials.

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

    def update_property_managerdetails(self,
                                       content_type,
                                       body,
                                       id):
        """Does a PUT request to /pm/{id}.

        This function will update a property manager’s details. In case of an
        update you do not need to pass all information, but if you have values
        in one section - all fields inside are mandatory.

        Args:
            content_type (string): TODO: type description here. Example: 
            body (CreatenewUpdatePropertyManagerRequest): TODO: type
                description here. Example: 
            id (string): Property Manager ID

        Returns:
            PropertyManagerdetailsresponse: 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 = '/pm/{id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'id': id
        })
        _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.put(_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, PropertyManagerdetailsresponse.from_dictionary)

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

        This API call will allow the PMS to pass all data to BookingPal that
        is required for registering a new PM (Property Manager). All fields
        are mandatory - PMS must pass this data in order for a PM account to
        be created. You need to use PMS credentials for this request.

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

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

    def get_property_managerdetaildata(self,
                                       content_type,
                                       id):
        """Does a GET request to /pm/{id}.

        This function will return a property manager’s details that belong to
        the current user. You need to use your PMS API credentials. 
        Request Body parameters are the same as for creating PM.
        Response is the same as in creating a Property Manager function. Here
        you do not need to pass all root level fields, but if some are used -
        all fields inside are mandatory:
        - in CompanyDetails Model you can pass any field, and none of them is
        mandatory
        - in Policies Model - you can pass any field,  and none of them is
        mandatory
        - if you do use PaymentPolicy - all fields inside are mandatory
        - if you do use CancellationPolicy - all fields inside are mandatory
        - if you use Payment Model - all fields inside are mandatory

        Args:
            content_type (string): TODO: type description here. Example: 
            id (string): Property Manager ID

        Returns:
            PropertyManagerdetailsresponse: 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 = '/pm/{id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'id': id
        })
        _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.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, PropertyManagerdetailsresponse.from_dictionary)
