"""
Binance Mining REST API

OpenAPI Specification for the Binance Mining 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.mining_api import MiningApi

from .models import AccountListResponse
from .models import AcquiringAlgorithmResponse
from .models import AcquiringCoinnameResponse
from .models import CancelHashrateResaleConfigurationResponse
from .models import EarningsListResponse
from .models import ExtraBonusListResponse
from .models import HashrateResaleDetailResponse
from .models import HashrateResaleListResponse
from .models import HashrateResaleRequestResponse
from .models import MiningAccountEarningResponse
from .models import RequestForDetailMinerListResponse
from .models import RequestForMinerListResponse
from .models import StatisticListResponse


T = TypeVar("T")


class MiningRestAPI:
    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._miningApi = MiningApi(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 account_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AccountListResponse]:
        """
                Account List(USER_DATA)

                Query Account List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[AccountListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.account_list(algo, user_name, recv_window)

    def acquiring_algorithm(
        self,
    ) -> ApiResponse[AcquiringAlgorithmResponse]:
        """
                Acquiring Algorithm(MARKET_DATA)

                Acquiring Algorithm

        Weight: 1

                Args:

                Returns:
                    ApiResponse[AcquiringAlgorithmResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.acquiring_algorithm()

    def acquiring_coinname(
        self,
    ) -> ApiResponse[AcquiringCoinnameResponse]:
        """
                Acquiring CoinName(MARKET_DATA)

                Acquiring CoinName

        Weight: 1

                Args:

                Returns:
                    ApiResponse[AcquiringCoinnameResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.acquiring_coinname()

    def cancel_hashrate_resale_configuration(
        self,
        config_id: Union[int, None],
        user_name: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelHashrateResaleConfigurationResponse]:
        """
                Cancel hashrate resale configuration(USER_DATA)


        Weight: 5

                Args:
                    config_id (Union[int, None]): Mining ID 168
                    user_name (Union[str, None]): Mining account test
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelHashrateResaleConfigurationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.cancel_hashrate_resale_configuration(
            config_id, user_name, recv_window
        )

    def earnings_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        coin: Optional[str] = None,
        start_date: Optional[int] = None,
        end_date: Optional[int] = None,
        page_index: Optional[int] = None,
        page_size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[EarningsListResponse]:
        """
                Earnings List(USER_DATA)

                Query Earnings List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    coin (Optional[str] = None): Coin Name
                    start_date (Optional[int] = None): Millisecond timestamp
                    end_date (Optional[int] = None): Millisecond timestamp
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    page_size (Optional[int] = None): Min 10,Max 200
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[EarningsListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.earnings_list(
            algo,
            user_name,
            coin,
            start_date,
            end_date,
            page_index,
            page_size,
            recv_window,
        )

    def extra_bonus_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        coin: Optional[str] = None,
        start_date: Optional[int] = None,
        end_date: Optional[int] = None,
        page_index: Optional[int] = None,
        page_size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ExtraBonusListResponse]:
        """
                Extra Bonus List(USER_DATA)

                Extra Bonus List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    coin (Optional[str] = None): Coin Name
                    start_date (Optional[int] = None): Millisecond timestamp
                    end_date (Optional[int] = None): Millisecond timestamp
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    page_size (Optional[int] = None): Min 10,Max 200
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ExtraBonusListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.extra_bonus_list(
            algo,
            user_name,
            coin,
            start_date,
            end_date,
            page_index,
            page_size,
            recv_window,
        )

    def hashrate_resale_detail(
        self,
        config_id: Union[int, None],
        user_name: Union[str, None],
        page_index: Optional[int] = None,
        page_size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[HashrateResaleDetailResponse]:
        """
                Hashrate Resale Detail(USER_DATA)

                Hashrate Resale Detail(USER_DATA)

        Weight: 5

                Args:
                    config_id (Union[int, None]): Mining ID 168
                    user_name (Union[str, None]): Mining account test
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    page_size (Optional[int] = None): Min 10,Max 200
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[HashrateResaleDetailResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.hashrate_resale_detail(
            config_id, user_name, page_index, page_size, recv_window
        )

    def hashrate_resale_list(
        self,
        page_index: Optional[int] = None,
        page_size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[HashrateResaleListResponse]:
        """
                Hashrate Resale List

                Hashrate Resale List

        Weight: 5

                Args:
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    page_size (Optional[int] = None): Min 10,Max 200
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[HashrateResaleListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.hashrate_resale_list(page_index, page_size, recv_window)

    def hashrate_resale_request(
        self,
        user_name: Union[str, None],
        algo: Union[str, None],
        end_date: Union[int, None],
        start_date: Union[int, None],
        to_pool_user: Union[str, None],
        hash_rate: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[HashrateResaleRequestResponse]:
        """
                Hashrate Resale Request(USER_DATA)

                Hashrate Resale Request

        Weight: 5

                Args:
                    user_name (Union[str, None]): Mining account test
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    end_date (Union[int, None]): Resale End Time (Millisecond timestamp) 1617659086000
                    start_date (Union[int, None]): Resale Start Time(Millisecond timestamp) 1607659086000
                    to_pool_user (Union[str, None]): Mining Account S19pro
                    hash_rate (Union[int, None]): Resale hashrate h/s must be transferred (BTC is greater than 500000000000 ETH is greater than 500000) 100000000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[HashrateResaleRequestResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.hashrate_resale_request(
            user_name, algo, end_date, start_date, to_pool_user, hash_rate, recv_window
        )

    def mining_account_earning(
        self,
        algo: Union[str, None],
        start_date: Optional[int] = None,
        end_date: Optional[int] = None,
        page_index: Optional[int] = None,
        page_size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[MiningAccountEarningResponse]:
        """
                Mining Account Earning(USER_DATA)

                Mining Account Earning

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    start_date (Optional[int] = None): Millisecond timestamp
                    end_date (Optional[int] = None): Millisecond timestamp
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    page_size (Optional[int] = None): Min 10,Max 200
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[MiningAccountEarningResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.mining_account_earning(
            algo, start_date, end_date, page_index, page_size, recv_window
        )

    def request_for_detail_miner_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        worker_name: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[RequestForDetailMinerListResponse]:
        """
                Request for Detail Miner List(USER_DATA)

                Request for Detail Miner List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    worker_name (Union[str, None]): Miner’s name(required) bhdc1.16A10404B
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[RequestForDetailMinerListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.request_for_detail_miner_list(
            algo, user_name, worker_name, recv_window
        )

    def request_for_miner_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        page_index: Optional[int] = None,
        sort: Optional[int] = None,
        sort_column: Optional[int] = None,
        worker_status: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[RequestForMinerListResponse]:
        """
                Request for Miner List(USER_DATA)

                Request for Miner List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    page_index (Optional[int] = None): Page number, empty default first page, starting from 1
                    sort (Optional[int] = None): sort sequence(default=0)0 positive sequence，1 negative sequence
                    sort_column (Optional[int] = None): Sort by( default 1): <br></br>1: miner name, <br></br>2: real-time computing power, <br></br>3: daily average computing power, <br></br>4: real-time rejection rate, <br></br>5: last submission time
                    worker_status (Optional[int] = None): miners status(default=0),0 all，1 valid，2 invalid，3 failure
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[RequestForMinerListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.request_for_miner_list(
            algo, user_name, page_index, sort, sort_column, worker_status, recv_window
        )

    def statistic_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[StatisticListResponse]:
        """
                Statistic List(USER_DATA)

                Statistic List

        Weight: 5

                Args:
                    algo (Union[str, None]): Algorithm(sha256) sha256
                    user_name (Union[str, None]): Mining account test
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[StatisticListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._miningApi.statistic_list(algo, user_name, recv_window)
