deribit_http/model/
custody.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub struct CustodyAccount {
10 #[serde(skip_serializing_if = "Option::is_none")]
12 pub id: Option<String>,
13 pub currency: String,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub balance: Option<f64>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub provider: Option<String>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub status: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub creation_timestamp: Option<u64>,
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_custody_account_deserialization() {
35 let json = r#"{
36 "id": "custody_123",
37 "currency": "BTC",
38 "balance": 1.5,
39 "provider": "fireblocks",
40 "status": "active"
41 }"#;
42
43 let account: CustodyAccount = serde_json::from_str(json).expect("Failed to parse");
44 assert_eq!(account.currency, "BTC");
45 assert_eq!(account.balance, Some(1.5));
46 assert_eq!(account.provider, Some("fireblocks".to_string()));
47 }
48
49 #[test]
50 fn test_custody_account_minimal() {
51 let json = r#"{
52 "currency": "ETH"
53 }"#;
54
55 let account: CustodyAccount = serde_json::from_str(json).expect("Failed to parse");
56 assert_eq!(account.currency, "ETH");
57 assert!(account.id.is_none());
58 }
59}