# -*- coding: utf-8 -*-

"""
zypev1

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

from zypev1.api_helper import APIHelper
from zypev1.configuration import Server
from zypev1.controllers.base_controller import BaseController
from zypev1.models.ad_tag_metadata import AdTagMetadata


class AdTagsController(BaseController):

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

    def __init__(self, config, call_back=None):
        super(AdTagsController, self).__init__(config, call_back)

    def ad_tags_get(self,
                    id=None,
                    active=None,
                    name=None,
                    disabled=None,
                    scope=None,
                    q=None,
                    order=None,
                    sort=None,
                    page=None,
                    per_page=None):
        """Does a GET request to /ad_tags.

        List Ad Tags

        Args:
            id (string, optional): Filter by ID + Examples     +
                `id=5628f9354d656c46285b0000`     + use
                `id!=5628f9354d656c46285b0000` to exclude by ID
            active (string, optional): Filter by active, inactive, or all
                records (Example: true)
            name (string, optional): Filter by name
            disabled (string, optional): Filter by disabled
            scope (string, optional): Filter by assigned scope: Options are
                'library' or 'video'
            q (string, optional): Filter by keyword
            order (string, optional): Filter by ascending or descending order
                + Examples     + asc     + desc
            sort (string, optional): Sort on the specified field
            page (float, optional): Number of pages to return
            per_page (float, optional): Number of records to return per page

        Returns:
            AdTagMetadata: 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 = '/ad_tags'
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_parameters = {
            'id': id,
            'active': active,
            'name': name,
            'disabled': disabled,
            'scope': scope,
            'q': q,
            'order': order,
            'sort': sort,
            'page': page,
            'per_page': per_page
        }
        _query_builder = APIHelper.append_url_with_query_parameters(
            _query_builder,
            _query_parameters
        )
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.config.http_client.get(_query_url, headers=_headers)
        _response = self.execute_request(_request)
        self.validate_response(_response)

        decoded = APIHelper.json_deserialize(_response.text, AdTagMetadata.from_dictionary)

        return decoded

    def ad_tags_post(self,
                     body,
                     id=None,
                     active=None,
                     name=None,
                     disabled=None,
                     scope=None,
                     order=None,
                     sort=None,
                     page=None,
                     per_page=None,
                     q=None):
        """Does a POST request to /ad_tags.

        Create Ad Tags

        Args:
            body (AdTagRequest): TODO: type description here.
            id (string, optional): TODO: type description here.
            active (string, optional): TODO: type description here.
            name (string, optional): TODO: type description here.
            disabled (string, optional): TODO: type description here.
            scope (string, optional): TODO: type description here.
            order (string, optional): TODO: type description here.
            sort (string, optional): TODO: type description here.
            page (string, optional): TODO: type description here.
            per_page (string, optional): TODO: type description here.
            q (string, optional): TODO: type description here.

        Returns:
            AdTagMetadata: 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 = '/ad_tags'
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_parameters = {
            'id': id,
            'active': active,
            'name': name,
            'disabled': disabled,
            'scope': scope,
            'order': order,
            'sort': sort,
            'page': page,
            'per_page': per_page,
            'q': q
        }
        _query_builder = APIHelper.append_url_with_query_parameters(
            _query_builder,
            _query_parameters
        )
        _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.config.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
        _response = self.execute_request(_request)
        self.validate_response(_response)

        decoded = APIHelper.json_deserialize(_response.text, AdTagMetadata.from_dictionary)

        return decoded

    def ad_tags_by_id_get(self,
                          id):
        """Does a GET request to /ad_tags/{id}.

        View Ad Tag

        Args:
            id (string): ID of the ad tag

        Returns:
            AdTagMetadata: 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 = '/ad_tags/{id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'id': {'value': id, 'encode': True}
        })
        _query_builder = self.config.get_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.config.http_client.get(_query_url, headers=_headers)
        _response = self.execute_request(_request)
        self.validate_response(_response)

        decoded = APIHelper.json_deserialize(_response.text, AdTagMetadata.from_dictionary)

        return decoded

    def ad_tags_by_id_put(self,
                          id,
                          body):
        """Does a PUT request to /ad_tags/{id}.

        Update Ad Tag

        Args:
            id (string): ID of the ad tag
            body (AdTagRequest): TODO: type description here.

        Returns:
            AdTagMetadata: 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 = '/ad_tags/{id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'id': {'value': id, 'encode': True}
        })
        _query_builder = self.config.get_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.config.http_client.put(_query_url, headers=_headers, parameters=APIHelper.json_serialize(body))
        _response = self.execute_request(_request)
        self.validate_response(_response)

        decoded = APIHelper.json_deserialize(_response.text, AdTagMetadata.from_dictionary)

        return decoded

    def ad_tags_by_id_delete(self,
                             id):
        """Does a DELETE request to /ad_tags/{id}.

        Delete Ad Tag

        Args:
            id (string): ID of the ad tag

        Returns:
            void: 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 = '/ad_tags/{id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, {
            'id': {'value': id, 'encode': True}
        })
        _query_builder = self.config.get_base_uri()
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare and execute request
        _request = self.config.http_client.delete(_query_url)
        _response = self.execute_request(_request)
        self.validate_response(_response)
