# -*- 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.getimagelistbyproduct_id import GetimagelistbyproductID

class ImagesController(BaseController):

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


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

        This function allows the logged in user to upload images for the
        existing product. Every new image will be sorted to the end. The first
        image sent will be used as the “Main Image”. (Image re-ordering can
        also be done within the BookingPal platform manually by users)

        Args:
            content_type (string): TODO: type description here. Example: 
            body (CreateimagesRequest): 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 = '/image'
        _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 getimagelistbyproduct_id(self,
                                 product_id):
        """Does a GET request to /image/{productId}.

        This function allows logged in user to get image list for the existing
        product

        Args:
            product_id (string): ID of the property

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

    def deleteallimagesperproperty(self,
                                   content_type,
                                   product_id):
        """Does a DELETE request to /image/{productId}.

        This function allows logged in user to delete images.

        Args:
            content_type (string): TODO: type description here. Example: 
            product_id (string): ID of property for which you want to delete
                all images

        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 = '/image/{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',
            'Content-Type': content_type
        }

        # Prepare and execute request
        _request = self.http_client.delete(_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 deletelistofimages(self,
                           content_type,
                           body):
        """Does a DELETE request to /image.

        This function allows the logged in user to delete image(s) from the
        existing product.

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