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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Account-related types.
use serde::{Deserialize, Serialize};
use super::Balance;
/// A Coinbase trading account.
#[derive(Debug, Clone, Deserialize)]
pub struct Account {
/// Unique identifier for the account.
pub uuid: String,
/// Display name of the account.
pub name: String,
/// Currency held in this account.
pub currency: String,
/// Available balance for trading.
pub available_balance: Balance,
/// Whether this is the default account for the currency.
pub default: bool,
/// Whether the account is active.
pub active: bool,
/// When the account was created.
pub created_at: String,
/// When the account was last updated.
pub updated_at: String,
/// When the account was deleted (if applicable).
pub deleted_at: Option<String>,
/// Account type (e.g., "ACCOUNT_TYPE_CRYPTO").
#[serde(rename = "type")]
pub account_type: String,
/// Whether the account is ready for use.
pub ready: bool,
/// Amount on hold (in orders, etc.).
pub hold: Balance,
/// The retail portfolio this account belongs to.
pub retail_portfolio_id: Option<String>,
}
/// Request parameters for listing accounts.
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListAccountsParams {
/// Maximum number of accounts to return.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u32>,
/// Cursor for pagination.
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<String>,
/// Filter by retail portfolio ID.
#[serde(skip_serializing_if = "Option::is_none")]
pub retail_portfolio_id: Option<String>,
}
impl ListAccountsParams {
/// Create new list accounts parameters.
pub fn new() -> Self {
Self::default()
}
/// Set the limit.
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
/// Set the cursor.
pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
self.cursor = Some(cursor.into());
self
}
/// Filter by portfolio ID.
pub fn portfolio(mut self, portfolio_id: impl Into<String>) -> Self {
self.retail_portfolio_id = Some(portfolio_id.into());
self
}
}
/// Response from listing accounts.
#[derive(Debug, Clone, Deserialize)]
pub struct ListAccountsResponse {
/// The list of accounts.
pub accounts: Vec<Account>,
/// Whether there are more accounts.
pub has_next: bool,
/// Cursor for the next page.
pub cursor: Option<String>,
/// Total size (if available).
pub size: Option<u32>,
}
/// Response from getting a single account.
#[derive(Debug, Clone, Deserialize)]
pub struct GetAccountResponse {
/// The account details.
pub account: Account,
}