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

"""
coingeckopublicapiv3

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

from coingeckopublicapiv3.api_helper import APIHelper
from coingeckopublicapiv3.configuration import Server
from coingeckopublicapiv3.controllers.base_controller import BaseController
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter
from coingeckopublicapiv3.http.http_method_enum import HttpMethodEnum
from apimatic_core.authentication.multiple.single_auth import Single
from apimatic_core.authentication.multiple.or_auth_group import Or
from coingeckopublicapiv3.models.categories_list import CategoriesList
from coingeckopublicapiv3.models.categories import Categories


class CategoriesController(BaseController):

    """A Controller to access Endpoints in the coingeckopublicapiv3 API."""
    def __init__(self, config):
        super(CategoriesController, self).__init__(config)

    def coins_categories_list(self):
        """Does a GET request to /coins/categories/list.

        This endpoint allows you to **query all the coins categories on
        CoinGecko**

        Returns:
            CategoriesList: Response from the API. List all categories

        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.

        """

        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path('/coins/categories/list')
            .http_method(HttpMethodEnum.GET)
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CategoriesList.from_dictionary)
        ).execute()

    def coins_categories(self,
                         order=None):
        """Does a GET request to /coins/categories.

        This endpoint allows you to **query all the coins categories with
        market data (market cap, volume, ...) on CoinGecko**

        Args:
            order (Order2Enum, optional): sort results by field, default:
                market_cap_desc

        Returns:
            Categories: Response from the API. List all categories with market
                data

        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.

        """

        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path('/coins/categories')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('order')
                         .value(order))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(Categories.from_dictionary)
        ).execute()
