xapi-binance 0.0.1

Binance API client
Documentation
use crate::{
    clients::spot::BnSpot,
    common::response::{BnRestRespType, BnWsApiRespType},
    data::{account_information::BnSpotAccountInformation, enums::ratelimit::BnRateLimitType},
};
use http::Method;
use nonzero_ext::nonzero;
use xapi_shared::rest::SharedRestClientTrait;

impl BnSpot {
    /// Get current account information.
    ///
    /// <https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data>
    pub async fn get_account_information(&self) -> BnRestRespType<BnSpotAccountInformation> {
        self.executor
            .call_with_no_payload(
                &[
                    (BnRateLimitType::RequestWeight, nonzero!(20u32)),
                    (BnRateLimitType::RawRequests, nonzero!(1u32)),
                ],
                true,
                Method::GET,
                self.executor
                    .get_endpoint()
                    .build_rest_api_url("/api/v3/account"),
            )
            .await
    }

    /// Query information about your account.
    ///
    /// <https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/account-requests#account-information-user_data>
    pub async fn get_account_information_ws(&self) -> BnWsApiRespType<BnSpotAccountInformation> {
        self.executor
            .call_ws_api(
                &[
                    (BnRateLimitType::RequestWeight, nonzero!(20u32)),
                    (BnRateLimitType::RawRequests, nonzero!(1u32)),
                ],
                true,
                "account.status",
                None::<()>,
            )
            .await
    }
}