# -*- 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.push_notification_links_response import PushNotificationLinksResponse

class PushNotificationController(BaseController):

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


    def get_notification_links(self):
        """Does a GET request to /info.

        This will return all notification URLs which are set. It will work on
        PMS level, so use PMS credentials.

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

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

        Provide the links on which the requests about new reservation and
        cancel reservation will be sent. Links should be https.
        These links should be set on PMS level, so please use your PMS
        credentials. 

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

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