# -*- 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.asset_platform import AssetPlatform
from coingeckopublicapiv3.models.token_lists import TokenLists


class AssetPlatformsController(BaseController):

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

    def asset_platforms_list(self,
                             filter=None):
        """Does a GET request to /asset_platforms.

        This endpoint allows you to **query all the asset platforms on
        CoinGecko**

        Args:
            filter (FilterEnum, optional): apply relevant filters to results

        Returns:
            List[AssetPlatform]: Response from the API. List all asset
                platforms

        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('/asset_platforms')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('filter')
                         .value(filter))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(AssetPlatform.from_dictionary)
        ).execute()

    def token_lists(self,
                    asset_platform_id):
        """Does a GET request to /token_lists/{asset_platform_id}/all.json.

        This endpoint allows you to **get full list of tokens of a blockchain
        network (asset platform) that is supported by [Ethereum token list
        standard](https://tokenlists.org/)**

        Args:
            asset_platform_id (str): asset platform ID <br> *refers to
                [`/asset_platforms`](/reference/asset-platforms-list)

        Returns:
            TokenLists: Response from the API. List all tokens on CoinGecko
                based on asset platform ID

        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('/token_lists/{asset_platform_id}/all.json')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('asset_platform_id')
                            .value(asset_platform_id)
                            .should_encode(True))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(TokenLists.from_dictionary)
        ).execute()
