crypto-rest-client 1.0.1

An RESTful client for all cryptocurrency exchanges.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crypto_market_type::MarketType;
use crypto_rest_client::fetch_l2_snapshot;
use serde_json::Value;
use std::collections::HashMap;

#[test]
fn test_l2_snapshot() {
    let text = fetch_l2_snapshot("bitget", MarketType::Spot, "BTCUSDT_SPBL", Some(3)).unwrap();
    let obj = serde_json::from_str::<HashMap<String, Value>>(&text).unwrap();

    assert_eq!(obj.get("msg").unwrap().as_str().unwrap(), "success");

    let data = obj.get("data").unwrap().as_object().unwrap();
    assert!(!data.get("asks").unwrap().as_array().unwrap().is_empty());
    assert!(!data.get("bids").unwrap().as_array().unwrap().is_empty());
}