monaco-sdk 0.8.1

Typed Rust client for the Monaco REST API — generated from the OpenAPI specification
Documentation
mod common;

use common::{client, first_pair_id};

#[tokio::test]
#[ignore = "requires running API server"]
async fn health_check() {
    let resp = client().health_check().await.unwrap().into_inner();
    assert!(resp.status.is_some());
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn list_trading_pairs() {
    let resp = client()
        .list_trading_pairs(None, Some(true), None, None, None, None)
        .await
        .unwrap()
        .into_inner();

    assert!(!resp.trading_pairs.unwrap().is_empty());
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn get_trading_pair_by_id() {
    let pair_id = first_pair_id().await;
    let resp = client()
        .get_trading_pair_by_id(&pair_id)
        .await
        .unwrap()
        .into_inner();

    assert!(resp.trading_pair.is_some());
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn get_market_metadata() {
    let pair_id = first_pair_id().await;
    let resp = client()
        .get_market_metadata(&pair_id)
        .await
        .unwrap()
        .into_inner();

    // Metadata is returned even if no trades have occurred
    let _ = resp.last_price;
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn get_orderbook() {
    let pair_id = first_pair_id().await;
    let resp = client()
        .get_orderbook_snapshot(&pair_id, None, None, None, None)
        .await
        .unwrap()
        .into_inner();

    assert!(resp.data.is_some());
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn get_trades() {
    let pair_id = first_pair_id().await;
    let resp = client()
        .get_trades(&pair_id, None, None)
        .await
        .unwrap()
        .into_inner();

    // Trades list may be empty if no trades yet, but fields must be present
    assert!(resp.trades.is_some());
    assert!(resp.page.is_some());
    assert!(resp.page_size.is_some());
}

#[tokio::test]
#[ignore = "requires running API server"]
async fn get_candles() {
    let pair_id = first_pair_id().await;
    let resp = client()
        .get_candles(&pair_id, "1h", None, None, None)
        .await
        .unwrap()
        .into_inner();

    // Empty candles is fine if no trades yet
    let _ = resp.candles;
}