bitbank-api 0.5.1

Rust library for bitbank API
Documentation
use super::*;

#[serde_as]
#[derive(Deserialize, Debug)]
pub struct Ticker {
    #[serde_as(deserialize_as = "DefaultOnNull<DisplayFromStr>")]
    pub sell: f64,
    #[serde_as(deserialize_as = "DefaultOnNull<DisplayFromStr>")]
    pub buy: f64,
    #[serde_as(as = "DisplayFromStr")]
    pub high: f64,
    #[serde_as(as = "DisplayFromStr")]
    pub low: f64,
    #[serde_as(as = "DisplayFromStr")]
    pub open: f64,
    #[serde_as(as = "DisplayFromStr")]
    pub last: f64,
    #[serde_as(as = "DisplayFromStr")]
    pub vol: f64,
    #[serde_as(as = "TimestampMilliSeconds")]
    pub timestamp: NaiveDateTime,
}

#[derive(TypedBuilder)]
pub struct Params {
    pair: Pair,
}

pub async fn get(params: Params) -> anyhow::Result<Ticker> {
    let pair = params.pair;
    let path = format!("/{}/ticker", pair);
    do_get(path).await
}

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test() -> anyhow::Result<()> {
        let params = Params::builder().pair(Pair(XRP, JPY)).build();
        let _ = get(params).await?;
        Ok(())
    }
}