1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! Private API methods.
//!
//! **Note: All this methods will panic if the client is not logged in.**

use failure::Error;
use lazy_static::lazy_static;
use reqwest::Url;

use crate::{types::*, ApiResult, Client, API_URL};

/// Private API methods.
///
/// **Note: All this methods will panic if the client is not logged in.**
impl Client {
    /// Gets the balances of the Bittrex account.
    ///
    /// **Note: it will panic if not logged in.**
    pub fn get_balances(&self) -> Result<Vec<BalanceInfo>, Error> {
        lazy_static! {
            /// URL for the `get_balances` endpoint.
            static ref URL: Url = API_URL.join("account/getbalances").unwrap();
        }
        let mut url = URL.clone();
        self.append_login(&mut url);

        let headers = self.get_headers(&url)?;
        let mut response = self.inner.get(url).headers(headers).send()?;
        let result: ApiResult<Vec<BalanceInfo>> = response.json()?;
        result.into_result()
    }
}