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
70
71
72
73
74
75
76
77
78
79
80
use chrono::{DateTime, Utc};
use reqwest::Method;
use serde::{Deserialize, Serialize};
use crate::client::{Client, PagedResponse, PaginationOptions, Response};
use crate::errors::Result;
use crate::transactions::Money;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Account {
pub id: String,
pub resource: String,
pub resource_path: String,
pub name: String,
pub primary: bool,
pub r#type: AccountType,
pub currency: AccountCurrency,
pub balance: Money,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum AccountType {
Wallet,
Fiat,
Vault,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AccountCurrency {
pub code: String,
pub name: String,
pub color: String,
pub sort_index: i32,
pub exponent: i32,
pub r#type: String,
pub address_regex: String,
pub asset_id: String,
pub slug: String,
}
impl Client {
pub async fn list_accounts(
&self,
pagination: &PaginationOptions,
) -> Result<PagedResponse<Account>> {
self.send_request(
Method::GET,
&format!("accounts{}", pagination.get_query()),
None::<&()>,
)
.await
}
pub async fn get_account(&self, account_id: &str) -> Result<Response<Account>> {
self.send_request(
Method::GET,
&format!("accounts/{}", account_id),
None::<&()>,
)
.await
}
}