"""
Binance Pay REST API

OpenAPI Specification for the Binance Pay 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
from requests import Session
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 ..models import GetPayTradeHistoryResponse


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

    def __init__(
        self,
        configuration: ConfigurationRestAPI = None,
        session: Session = None,
        signer: Signers = None,
    ) -> None:
        self._configuration = configuration
        self._session = session
        self._signer = signer

    def get_pay_trade_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetPayTradeHistoryResponse]:
        """
                Get Pay Trade History
                GET /sapi/v1/pay/transactions
                https://developers.binance.com/docs/pay/rest-api/Get-Pay-Trade-History

                Get Pay Trade History

        * If startTime and endTime are not sent, the recent 90 days' data will be returned.
        * The max interval between startTime and endTime is 90 days.
        * Support for querying orders within the last 18 months.
        * For payerInfo and receiverInfo，there are different return values in different orderTypes.
        * Sender's perspective when orderType is C2C
        * payerInfo : binanceId
        * receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input)
        * Receiver's perspective when orderType is C2C
        * payerInfo : name
        * receiverInfo : binanceId
        * Sender's perspective when orderType is CRYPTO_BOX
        * payerInfo : binanceId
        * receiverInfo : name(the value is always "Crypto Box")
        * Receiver's perspective when orderType is CRYPTO_BOX
        * payerInfo : name
        * receiverInfo : binanceId
        * Sender's perspective when orderType is PAY
        * payerInfo : binanceId
        * receiverInfo : name
        * Receiver's perspective when orderType is PAY
        * payerInfo : name
        * receiverInfo : binanceId, name
        * Sender's perspective when orderType is PAY_REFUND
        * payerInfo : binanceId, name
        * receiverInfo : name, accountId
        * Receiver's perspective when orderType is PAY_REFUND
        * payerInfo : name
        * receiverInfo :  binanceId
        * Sender's perspective when orderType is PAYOUT
        * payerInfo : binanceId, name
        * receiverInfo : name, accountId
        * Receiver's perspective when orderType is PAYOUT
        * payerInfo : name
        * receiverInfo :  binanceId
        * Receiver's perspective when orderType is CRYPTO_BOX_RF
        * payerInfo : name(the value is always "Crypto Box")
        * receiverInfo : binanceId
        * Sender's perspective when orderType is REMITTANCE
        * payerInfo : binanceId
        * receiverInfo : name, institutionName, cardNumber, digitalWalletId

        Weight: 3000

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    limit (Optional[int] = None): default 100, max 100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetPayTradeHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/pay/transactions",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPayTradeHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )
