# -*- 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.coins_list import CoinsList
from coingeckopublicapiv3.models.coins_markets import CoinsMarkets
from coingeckopublicapiv3.models.coins_data_base import CoinsDataBase
from coingeckopublicapiv3.models.coins_tickers import CoinsTickers
from coingeckopublicapiv3.models.coins_historical_data import CoinsHistoricalData
from coingeckopublicapiv3.models.coins_market_chart import CoinsMarketChart
from coingeckopublicapiv3.models.coins_market_chart_range import CoinsMarketChartRange


class CoinsController(BaseController):

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

    def coins_list(self,
                   include_platform=None):
        """Does a GET request to /coins/list.

        This endpoint allows you to **query all the supported coins on
        CoinGecko with coins ID, name and symbol**

        Args:
            include_platform (bool, optional): include platform and token's
                contract addresses, default: false

        Returns:
            List[CoinsList]: Response from the API. List all coins with ID,
                name, and symbol

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

    def coins_markets(self,
                      vs_currency,
                      ids=None,
                      names=None,
                      symbols=None,
                      include_tokens=None,
                      category=None,
                      order=None,
                      per_page=None,
                      page=None,
                      sparkline=None,
                      price_change_percentage=None,
                      locale=None,
                      precision=None):
        """Does a GET request to /coins/markets.

        This endpoint allows you to **query all the supported coins with
        price, market cap, volume and market related data**

        Args:
            vs_currency (str): target currency of coins and market data <br>
                *refers to
                [`/simple/supported_vs_currencies`](/reference/simple-supported
                -currencies).
            ids (str, optional): coins' IDs, comma-separated if querying more
                than 1 coin. <br> *refers to
                [`/coins/list`](/reference/coins-list).
            names (str, optional): coins' names, comma-separated if querying
                more than 1 coin.
            symbols (str, optional): coins' symbols, comma-separated if
                querying more than 1 coin.
            include_tokens (IncludeTokensEnum, optional): for `symbols`
                lookups, specify `all` to include all matching tokens <br>
                Default `top` returns top-ranked tokens (by market cap or
                volume)
            category (str, optional): filter based on coins' category <br>
                *refers to
                [`/coins/categories/list`](/reference/coins-categories-list).
            order (OrderEnum, optional): sort result by field, default:
                market_cap_desc
            per_page (int, optional): total results per page, default: 100
                <br> Valid values: 1...250
            page (int, optional): page through results, default: 1
            sparkline (bool, optional): include sparkline 7 days data,
                default: false
            price_change_percentage (str, optional): include price change
                percentage timeframe, comma-separated if query more than 1
                price change percentage timeframe <br> Valid values: 1h, 24h,
                7d, 14d, 30d, 200d, 1y
            locale (LocaleEnum, optional): language background, default: en
            precision (PrecisionEnum, optional): decimal place for currency
                price value

        Returns:
            CoinsMarkets: Response from the API. List all coins 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/markets')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('vs_currency')
                         .value(vs_currency))
            .query_param(Parameter()
                         .key('ids')
                         .value(ids))
            .query_param(Parameter()
                         .key('names')
                         .value(names))
            .query_param(Parameter()
                         .key('symbols')
                         .value(symbols))
            .query_param(Parameter()
                         .key('include_tokens')
                         .value(include_tokens))
            .query_param(Parameter()
                         .key('category')
                         .value(category))
            .query_param(Parameter()
                         .key('order')
                         .value(order))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('sparkline')
                         .value(sparkline))
            .query_param(Parameter()
                         .key('price_change_percentage')
                         .value(price_change_percentage))
            .query_param(Parameter()
                         .key('locale')
                         .value(locale))
            .query_param(Parameter()
                         .key('precision')
                         .value(precision))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CoinsMarkets.from_dictionary)
        ).execute()

    def coins_id(self,
                 id,
                 localization=None,
                 tickers=None,
                 market_data=None,
                 community_data=None,
                 developer_data=None,
                 sparkline=None,
                 dex_pair_format=None):
        """Does a GET request to /coins/{id}.

        This endpoint allows you to **query all the metadata (image, websites,
        socials, description, contract address, etc.) and market data (price,
        ATH, exchange tickers, etc.) of a coin from the CoinGecko coin page
        based on a particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            localization (bool, optional): include all the localized languages
                in the response, default: true
            tickers (bool, optional): include tickers data, default: true
            market_data (bool, optional): include market data, default: true
            community_data (bool, optional): include community data, default:
                true
            developer_data (bool, optional): include developer data, default:
                true
            sparkline (bool, optional): include sparkline 7 days data,
                default: false
            dex_pair_format (DexPairFormatEnum, optional): set to `symbol` to
                display DEX pair base and target as symbols, default:
                `contract_address`

        Returns:
            CoinsDataBase: Response from the API. Get current data for a coin

        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/{id}')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('localization')
                         .value(localization))
            .query_param(Parameter()
                         .key('tickers')
                         .value(tickers))
            .query_param(Parameter()
                         .key('market_data')
                         .value(market_data))
            .query_param(Parameter()
                         .key('community_data')
                         .value(community_data))
            .query_param(Parameter()
                         .key('developer_data')
                         .value(developer_data))
            .query_param(Parameter()
                         .key('sparkline')
                         .value(sparkline))
            .query_param(Parameter()
                         .key('dex_pair_format')
                         .value(dex_pair_format))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CoinsDataBase.from_dictionary)
        ).execute()

    def coins_id_tickers(self,
                         id,
                         exchange_ids=None,
                         include_exchange_logo=None,
                         page=None,
                         order=None,
                         depth=None,
                         dex_pair_format=None):
        """Does a GET request to /coins/{id}/tickers.

        This endpoint allows you to **query the coin tickers on both
        centralized exchange (CEX) and decentralized exchange (DEX) based on a
        particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            exchange_ids (str, optional): exchange ID <br> *refers to
                [`/exchanges/list`](/reference/exchanges-list).
            include_exchange_logo (bool, optional): include exchange logo,
                default: false
            page (int, optional): page through results
            order (Order1Enum, optional): use this to sort the order of
                responses, default: trust_score_desc
            depth (bool, optional): include 2% orderbook depth, ie.
                `cost_to_move_up_usd` and `cost_to_move_down_usd` <br>
                Default: false
            dex_pair_format (DexPairFormatEnum, optional): set to `symbol` to
                display DEX pair base and target as symbols, default:
                `contract_address`

        Returns:
            CoinsTickers: Response from the API. Get coin tickers

        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/{id}/tickers')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('exchange_ids')
                         .value(exchange_ids))
            .query_param(Parameter()
                         .key('include_exchange_logo')
                         .value(include_exchange_logo))
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('order')
                         .value(order))
            .query_param(Parameter()
                         .key('depth')
                         .value(depth))
            .query_param(Parameter()
                         .key('dex_pair_format')
                         .value(dex_pair_format))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CoinsTickers.from_dictionary)
        ).execute()

    def coins_id_history(self,
                         id,
                         date,
                         localization=None):
        """Does a GET request to /coins/{id}/history.

        This endpoint allows you to **query the historical data (price, market
        cap, 24hrs volume, ...) at a given date for a coin based on a
        particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            date (str): the date of data snapshot <br> Format: `dd-mm-yyyy`
            localization (bool, optional): include all the localized languages
                in response, default: true

        Returns:
            CoinsHistoricalData: Response from the API. Get historical data
                (name, price, market, stats) at a given date for a coin

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

    def coins_id_market_chart(self,
                              id,
                              vs_currency,
                              days,
                              interval=None,
                              precision=None):
        """Does a GET request to /coins/{id}/market_chart.

        This endpoint allows you to **get the historical chart data of a coin
        including time in UNIX, price, market cap and 24hr volume based on
        particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            vs_currency (str): target currency of market data <br> *refers to
                [`/simple/supported_vs_currencies`](/reference/simple-supported
                -currencies).
            days (str): data up to number of days ago <br> You may use any
                integer for number of days
            interval (IntervalEnum, optional): data interval, leave empty for
                auto granularity Possible value: daily
            precision (PrecisionEnum, optional): decimal place for currency
                price value

        Returns:
            CoinsMarketChart: Response from the API. Get historical market
                data include price, market cap, and 24hr volume (granularity
                auto)

        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/{id}/market_chart')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('vs_currency')
                         .value(vs_currency))
            .query_param(Parameter()
                         .key('days')
                         .value(days))
            .query_param(Parameter()
                         .key('interval')
                         .value(interval))
            .query_param(Parameter()
                         .key('precision')
                         .value(precision))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CoinsMarketChart.from_dictionary)
        ).execute()

    def coins_id_market_chart_range(self,
                                    id,
                                    vs_currency,
                                    mfrom,
                                    to,
                                    precision=None):
        """Does a GET request to /coins/{id}/market_chart/range.

        This endpoint allows you to **get the historical chart data of a coin
        within certain time range in UNIX along with price, market cap and
        24hr volume based on particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            vs_currency (str): target currency of market data <br> *refers to
                [`/simple/supported_vs_currencies`](/reference/simple-supported
                -currencies).
            mfrom (int): starting date in UNIX timestamp
            to (int): ending date in UNIX timestamp
            precision (PrecisionEnum, optional): decimal place for currency
                price value

        Returns:
            CoinsMarketChartRange: Response from the API. Get historical
                market data include price, market cap, and 24hr volume
                (granularity auto)

        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/{id}/market_chart/range')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('vs_currency')
                         .value(vs_currency))
            .query_param(Parameter()
                         .key('from')
                         .value(mfrom))
            .query_param(Parameter()
                         .key('to')
                         .value(to))
            .query_param(Parameter()
                         .key('precision')
                         .value(precision))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CoinsMarketChartRange.from_dictionary)
        ).execute()

    def coins_id_ohlc(self,
                      id,
                      vs_currency,
                      days,
                      precision=None):
        """Does a GET request to /coins/{id}/ohlc.

        This endpoint allows you to **get the OHLC chart (Open, High, Low,
        Close) of a coin based on particular coin ID**

        Args:
            id (str): coin ID <br> *refers to
                [`/coins/list`](/reference/coins-list).
            vs_currency (str): target currency of price data <br> *refers to
                [`/simple/supported_vs_currencies`](/reference/simple-supported
                -currencies).
            days (DaysEnum): data up to number of days ago
            precision (PrecisionEnum, optional): decimal place for currency
                price value

        Returns:
            List[float]: Response from the API. Get coin's OHLC

        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/{id}/ohlc')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(id)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('vs_currency')
                         .value(vs_currency))
            .query_param(Parameter()
                         .key('days')
                         .value(days))
            .query_param(Parameter()
                         .key('precision')
                         .value(precision))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
        ).execute()
