lamarge 0.5.1

Client for the LaMarge API: sign-in, takes, transfers, withdrawals and market making, each request checked before it is signed.
Documentation
//! The session's account: profile, balances, statistics, exposure, venue setup, wallet funding,
//! escrow orders and links.

use super::Account;
use crate::{
    Result,
    model::{Balance, EscrowOrder, Exposure, Me, Stats, VenueSetup, WalletFunding},
    transport::{Call, ops},
    types::{TakeId, VenueId},
};

impl Account<'_> {
    /// The signed-in user and its linked accounts (`GET /v1/me`).
    pub async fn me(&self) -> Result<Me> {
        self.inner.send(Call::new(&ops::GET_ME), self.auth).await
    }

    /// The linked accounts' funds, one per venue (`GET /v1/balances`).
    pub async fn balances(&self) -> Result<Vec<Balance>> {
        self.inner.send(Call::new(&ops::GET_BALANCES), self.auth).await
    }

    /// Trading statistics (`GET /v1/me/stats`).
    pub async fn stats(&self) -> Result<Stats> {
        self.inner.send(Call::new(&ops::GET_STATS), self.auth).await
    }

    /// Funds committed to trading (`GET /v1/me/exposure`).
    pub async fn exposure(&self) -> Result<Exposure> {
        self.inner.send(Call::new(&ops::GET_EXPOSURE), self.auth).await
    }

    /// The setup of the account linked on `venue` (`GET /v1/accounts/{venue}/setup`).
    pub async fn venue_setup(&self, venue: &VenueId) -> Result<VenueSetup> {
        self.inner.send(Call::new(&ops::GET_VENUE_SETUP).segment(venue), self.auth).await
    }

    /// The session address's wallet funds on `venue`'s escrow chain; with `take`, as that
    /// unpaid take may spend them (`GET /v1/wallets/{venue}`).
    pub async fn wallet_funding(
        &self,
        venue: &VenueId,
        take: Option<TakeId>,
    ) -> Result<WalletFunding> {
        let mut call = Call::new(&ops::GET_WALLET_FUNDING).segment(venue);
        if let Some(take) = take {
            call = call.query("take_id", take);
        }
        self.inner.send(call, self.auth).await
    }

    /// The linked addresses' escrow orders with unlocked funds (`GET /v1/escrow`).
    pub async fn escrow(&self) -> Result<Vec<EscrowOrder>> {
        self.inner.send(Call::new(&ops::GET_ESCROW), self.auth).await
    }

    /// Unlinks the account on `venue` (`DELETE /v1/accounts/{venue}`).
    pub async fn unlink(&self, venue: &VenueId) -> Result<()> {
        self.inner.send(Call::new(&ops::DELETE_LINK).segment(venue), self.auth).await
    }
}

#[cfg(test)]
mod tests;