"""
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.
"""

from typing import Optional, Union
from requests import Session
from binance_common.configuration import ConfigurationRestAPI
from binance_common.errors import RequiredError
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

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


class MiningApi:
    """API Client for MiningApi endpoints."""

    def __init__(
        self,
        configuration: ConfigurationRestAPI = None,
        session: Session = None,
        signer: Signers = None,
    ) -> None:
        self._configuration = configuration
        self._session = session
        self._signer = 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)
                GET /sapi/v1/mining/statistics/user/list
                https://developers.binance.com/docs/mining/rest-api/Account-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {"algo": algo, "user_name": user_name, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/statistics/user/list",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=AccountListResponse,
            is_signed=True,
            signer=self._signer,
        )

    def acquiring_algorithm(
        self,
    ) -> ApiResponse[AcquiringAlgorithmResponse]:
        """
                Acquiring Algorithm(MARKET_DATA)
                GET /sapi/v1/mining/pub/algoList
                https://developers.binance.com/docs/mining/rest-api/Acquiring-Algorithm

                Acquiring Algorithm

        Weight: 1

                Args:

                Returns:
                    ApiResponse[AcquiringAlgorithmResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/pub/algoList",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=AcquiringAlgorithmResponse,
        )

    def acquiring_coinname(
        self,
    ) -> ApiResponse[AcquiringCoinnameResponse]:
        """
                Acquiring CoinName(MARKET_DATA)
                GET /sapi/v1/mining/pub/coinList
                https://developers.binance.com/docs/mining/rest-api/Acquiring-CoinName

                Acquiring CoinName

        Weight: 1

                Args:

                Returns:
                    ApiResponse[AcquiringCoinnameResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/pub/coinList",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=AcquiringCoinnameResponse,
        )

    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)
                POST /sapi/v1/mining/hash-transfer/config/cancel
                https://developers.binance.com/docs/mining/rest-api/Cancel-hashrate-resale-configuration


        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.

        """

        if config_id is None:
            raise RequiredError(
                field="config_id",
                error_message="Missing required parameter 'config_id'",
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {
            "config_id": config_id,
            "user_name": user_name,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/mining/hash-transfer/config/cancel",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelHashrateResaleConfigurationResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/payment/list
                https://developers.binance.com/docs/mining/rest-api/Earnings-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {
            "algo": algo,
            "user_name": user_name,
            "coin": coin,
            "start_date": start_date,
            "end_date": end_date,
            "page_index": page_index,
            "page_size": page_size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/payment/list",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=EarningsListResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/payment/other
                https://developers.binance.com/docs/mining/rest-api/Extra-Bonus-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {
            "algo": algo,
            "user_name": user_name,
            "coin": coin,
            "start_date": start_date,
            "end_date": end_date,
            "page_index": page_index,
            "page_size": page_size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/payment/other",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ExtraBonusListResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/hash-transfer/profit/details
                https://developers.binance.com/docs/mining/rest-api/Hashrate-Resale-Detail

                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.

        """

        if config_id is None:
            raise RequiredError(
                field="config_id",
                error_message="Missing required parameter 'config_id'",
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {
            "config_id": config_id,
            "user_name": user_name,
            "page_index": page_index,
            "page_size": page_size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/hash-transfer/profit/details",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=HashrateResaleDetailResponse,
            is_signed=True,
            signer=self._signer,
        )

    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
                GET /sapi/v1/mining/hash-transfer/config/details/list
                https://developers.binance.com/docs/mining/rest-api/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.

        """

        body = {}
        payload = {
            "page_index": page_index,
            "page_size": page_size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/hash-transfer/config/details/list",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=HashrateResaleListResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                POST /sapi/v1/mining/hash-transfer/config
                https://developers.binance.com/docs/mining/rest-api/Hashrate-Resale-Request

                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.

        """

        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )
        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if end_date is None:
            raise RequiredError(
                field="end_date", error_message="Missing required parameter 'end_date'"
            )
        if start_date is None:
            raise RequiredError(
                field="start_date",
                error_message="Missing required parameter 'start_date'",
            )
        if to_pool_user is None:
            raise RequiredError(
                field="to_pool_user",
                error_message="Missing required parameter 'to_pool_user'",
            )
        if hash_rate is None:
            raise RequiredError(
                field="hash_rate",
                error_message="Missing required parameter 'hash_rate'",
            )

        body = {}
        payload = {
            "user_name": user_name,
            "algo": algo,
            "end_date": end_date,
            "start_date": start_date,
            "to_pool_user": to_pool_user,
            "hash_rate": hash_rate,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/mining/hash-transfer/config",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=HashrateResaleRequestResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/payment/uid
                https://developers.binance.com/docs/mining/rest-api/Mining-Account-Earning

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )

        body = {}
        payload = {
            "algo": algo,
            "start_date": start_date,
            "end_date": end_date,
            "page_index": page_index,
            "page_size": page_size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/payment/uid",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=MiningAccountEarningResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/worker/detail
                https://developers.binance.com/docs/mining/rest-api/Request-for-Detail-Miner-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )
        if worker_name is None:
            raise RequiredError(
                field="worker_name",
                error_message="Missing required parameter 'worker_name'",
            )

        body = {}
        payload = {
            "algo": algo,
            "user_name": user_name,
            "worker_name": worker_name,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/worker/detail",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=RequestForDetailMinerListResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                GET /sapi/v1/mining/worker/list
                https://developers.binance.com/docs/mining/rest-api/Request-for-Miner-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {
            "algo": algo,
            "user_name": user_name,
            "page_index": page_index,
            "sort": sort,
            "sort_column": sort_column,
            "worker_status": worker_status,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/worker/list",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=RequestForMinerListResponse,
            is_signed=True,
            signer=self._signer,
        )

    def statistic_list(
        self,
        algo: Union[str, None],
        user_name: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[StatisticListResponse]:
        """
                Statistic List(USER_DATA)
                GET /sapi/v1/mining/statistics/user/status
                https://developers.binance.com/docs/mining/rest-api/Statistic-List

                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.

        """

        if algo is None:
            raise RequiredError(
                field="algo", error_message="Missing required parameter 'algo'"
            )
        if user_name is None:
            raise RequiredError(
                field="user_name",
                error_message="Missing required parameter 'user_name'",
            )

        body = {}
        payload = {"algo": algo, "user_name": user_name, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/mining/statistics/user/status",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=StatisticListResponse,
            is_signed=True,
            signer=self._signer,
        )
