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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(unused_imports, unreachable_code, unused_variables)]
use std::collections::BTreeMap;

use serde_json::Value;
use crate::api::{API, Account};
use crate::client::Client;
use crate::errors::Result;

use crate::model::*;
use crate::util::{build_json_request, build_request};


#[derive(Clone)]
pub struct AccountManager {
  pub client: Client,
  pub recv_window: u64,
}

impl AccountManager {
    pub async fn get_wallet_balance<'a>(&self, req: WalletRequest<'a>) -> Result<Value> {
     let mut parameters: BTreeMap<String, Value> = BTreeMap::new(); 
     parameters.insert("accountType".into(), req.account_type.into());
     if let Some(c) = req.coin {
        parameters.insert("coin".into(), c.into());
     }
     let request = build_request(&parameters);
     let _response: Value = self
        .client
        .get_signed(API::Account(Account::Balance), self.recv_window.into(), Some(request))
        .await?;
      todo!("This endpoint has issues authenticating signatures" );
     Ok(_response)
    }

    pub async  fn get_account_info(&self) -> Result<Value> {
        let response: Value = self
           .client
           .get_signed(API::Account(Account::Information), self.recv_window.into(), None)
           .await?;
        Ok(response)
    } 

    pub async fn get_collateral_info(&self, coin: String) -> Result<Value> {
      let mut parameters: BTreeMap<String, Value> = BTreeMap::new();
      parameters.insert("currency".into(), coin.into());
      let req  = build_request(&parameters);
        let _response: Value = self
           .client
           .get_signed(API::Account(Account::CollateralInfo), self.recv_window.into(), Some(req))
           .await?;
          todo!("This endpoint has issues authenticating signatures" );
        Ok(_response)
    }

    pub async fn get_fee_rate(&self, category: Category, symbol: Option<String>) -> Result<Value> {
      let mut parameters: BTreeMap<String, Value> = BTreeMap::new();
      if let Some(s) = symbol {
        parameters.insert("symbol".into(), s.into());
      }
      let req  = build_request(&parameters);
        let _response: Value = self
           .client
           .get_signed(API::Account(Account::FeeRate), self.recv_window.into(), Some(req))
           .await?;
          todo!("This endpoint has issues authenticating signatures" );
        Ok(_response)
    }

}