# -*- 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.nft_list import NFTList
from coingeckopublicapiv3.models.nft_data import NFTData


class NFTsBetaController(BaseController):

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

    def nfts_list(self,
                  order=None,
                  per_page=None,
                  page=None):
        """Does a GET request to /nfts/list.

        This endpoint allows you to **query all supported NFTs with ID,
        contract address, name, asset platform ID and symbol on CoinGecko**

        Args:
            order (Order5Enum, optional): use this to sort the order of
                responses
            per_page (int, optional): total results per page <br> Valid
                values: 1...250
            page (int, optional): page through results

        Returns:
            NFTList: Response from the API. List all NFTs 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('/nfts/list')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('order')
                         .value(order))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Or(Single('apiKeyAuth'), Single('apiKeyQueryParam')))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(NFTList.from_dictionary)
        ).execute()

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

        This endpoint allows you to **query all the NFT data (name, floor
        price, 24hr volume ...) based on the NFT collection ID**

        Args:
            id (str): NFTs ID <br> *refers to
                [`/nfts/list`](/reference/nfts-list).

        Returns:
            NFTData: Response from the API. Get NFTs 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('/nfts/{id}')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('id')
                            .value(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(NFTData.from_dictionary)
        ).execute()

    def nfts_contract_address(self,
                              asset_platform_id,
                              contract_address):
        """Does a GET request to /nfts/{asset_platform_id}/contract/{contract_address}.

        This endpoint allows you to **query all the NFT data (name, floor
        price, 24hr volume ...) based on the NFT collection contract address
        and respective asset platform**

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

        Returns:
            NFTData: Response from the API. Get NFTs 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('/nfts/{asset_platform_id}/contract/{contract_address}')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('asset_platform_id')
                            .value(asset_platform_id)
                            .should_encode(True))
            .template_param(Parameter()
                            .key('contract_address')
                            .value(contract_address)
                            .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(NFTData.from_dictionary)
        ).execute()
