"""
Binance C2C REST API

OpenAPI Specification for the Binance C2C 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 GetC2CTradeHistoryResponse


class C2CApi:
    """API Client for C2CApi 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_c2_c_trade_history(
        self,
        trade_type: Optional[str] = None,
        start_timestamp: Optional[int] = None,
        end_timestamp: Optional[int] = None,
        page: Optional[int] = None,
        rows: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetC2CTradeHistoryResponse]:
        """
                Get C2C Trade History (USER_DATA)
                GET /sapi/v1/c2c/orderMatch/listUserOrderHistory
                https://developers.binance.com/docs/c2c/rest-api/Get-C2C-Trade-History

                Get C2C Trade History

        * The max interval between startTimestamp and endTimestamp is 30 days.
        * If startTimestamp and endTimestamp are not sent, the recent 30 days' data will be returned.
        * You can only view data from the past 6 months. To see all C2C orders, please check https://c2c.binance.com/en/fiatOrder

        Weight: 1

                Args:
                    trade_type (Optional[str] = None): BUY, SELL
                    start_timestamp (Optional[int] = None):
                    end_timestamp (Optional[int] = None):
                    page (Optional[int] = None): Default 1
                    rows (Optional[int] = None): default 100, max 100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetC2CTradeHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "trade_type": trade_type,
            "start_timestamp": start_timestamp,
            "end_timestamp": end_timestamp,
            "page": page,
            "rows": rows,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/c2c/orderMatch/listUserOrderHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetC2CTradeHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )
