"""
Binance NFT REST API

OpenAPI Specification for the Binance NFT REST API
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

import requests
from typing import Optional, TypeVar, Union
from binance_common.configuration import ConfigurationRestAPI
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request
from .api.nft_api import NFTApi

from .models import GetNFTAssetResponse
from .models import GetNFTDepositHistoryResponse
from .models import GetNFTTransactionHistoryResponse
from .models import GetNFTWithdrawHistoryResponse


T = TypeVar("T")


class NFTRestAPI:
    def __init__(
        self,
        configuration: ConfigurationRestAPI,
    ) -> None:
        self.configuration = configuration
        self._session = requests.Session()
        self._signer = (
            Signers.get_signer(
                configuration.private_key, configuration.private_key_passphrase
            )
            if configuration.private_key is not None
            else None
        )

        self._nFTApi = NFTApi(self.configuration, self._session, self._signer)

    def send_request(
        self,
        endpoint: str,
        method: str,
        query_params: Optional[dict] = None,
        body_params: Optional[dict] = None,
    ) -> ApiResponse[T]:
        """
        Sends an request to the Binance REST API.

        Args:
            endpoint (str): The API endpoint path to send the request to.
            method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
            query_params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
            body_params (Optional[dict]): The request body as a dictionary, or None if no body is required.

        Returns:
            ApiResponse[T]: The API response, where T is the expected response type.
        """
        return send_request[T](
            self._session,
            self.configuration,
            method,
            endpoint,
            query_params,
            body_params,
        )

    def send_signed_request(
        self,
        endpoint: str,
        method: str,
        query_params: Optional[dict] = None,
        body_params: Optional[dict] = None,
    ) -> ApiResponse[T]:
        """
        Sends a signed request to the Binance REST API.

        Args:
            endpoint (str): The API endpoint path to send the request to.
            method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
            query_params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
            body_params (Optional[dict]): The request body as a dictionary, or None if no body is required.

        Returns:
            ApiResponse[T]: The API response, where T is the expected response type.
        """
        return send_request[T](
            self._session,
            self.configuration,
            method,
            endpoint,
            query_params,
            body_params,
            is_signed=True,
            signer=self._signer,
        )

    def get_nft_asset(
        self,
        limit: Optional[int] = None,
        page: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetNFTAssetResponse]:
        """
                Get NFT Asset(USER_DATA)

                Get NFT Asset

        Weight: 3000

                Args:
                    limit (Optional[int] = None): Default 50, Max 50
                    page (Optional[int] = None): Default 1
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetNFTAssetResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._nFTApi.get_nft_asset(limit, page, recv_window)

    def get_nft_deposit_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        page: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetNFTDepositHistoryResponse]:
        """
                Get NFT Deposit History(USER_DATA)

                et NFT Deposit History


        * The max interval between startTime and endTime is 90 days.
        * If startTime and endTime are not sent, the recent 7 days' data will be returned.

        Weight: 3000

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    limit (Optional[int] = None): Default 50, Max 50
                    page (Optional[int] = None): Default 1
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetNFTDepositHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._nFTApi.get_nft_deposit_history(
            start_time, end_time, limit, page, recv_window
        )

    def get_nft_transaction_history(
        self,
        order_type: Union[int, None],
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        page: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetNFTTransactionHistoryResponse]:
        """
                Get NFT Transaction History(USER_DATA)

                Get NFT Transaction History

        * The max interval between startTime and endTime is 90 days.
        * If startTime and endTime are not sent, the recent 7 days' data will be returned.

        Weight: 3000

                Args:
                    order_type (Union[int, None]): 0: purchase order, 1: sell order, 2: royalty income, 3: primary market order, 4: mint fee
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    limit (Optional[int] = None): Default 50, Max 50
                    page (Optional[int] = None): Default 1
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetNFTTransactionHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._nFTApi.get_nft_transaction_history(
            order_type, start_time, end_time, limit, page, recv_window
        )

    def get_nft_withdraw_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        page: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetNFTWithdrawHistoryResponse]:
        """
                Get NFT Withdraw History(USER_DATA)

                Get NFT Withdraw History

        * The max interval between startTime and endTime is 90 days.
        * If startTime and endTime are not sent, the recent 7 days' data will be returned.

        Weight: 3000

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    limit (Optional[int] = None): Default 50, Max 50
                    page (Optional[int] = None): Default 1
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetNFTWithdrawHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._nFTApi.get_nft_withdraw_history(
            start_time, end_time, limit, page, recv_window
        )
