1#![allow(unused)]
2
3use crate::prelude::*;
4
5pub struct WalletGroup<'a> {
7 pub(crate) esi: &'a Esi,
8}
9
10impl WalletGroup<'_> {
11 api_get!(
12 get_wallet,
14 "GetCharactersCharacterIdWallet",
15 RequestType::Authenticated,
16 f64,
17 (character_id: i64) => "{character_id}"
18 );
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
23#[serde(rename_all = "snake_case")]
24pub enum JournalContextType {
25 StructureId,
27 StationId,
29 MarketTransactionId,
31 CharacterId,
33 CorporationId,
35 AllianceId,
37 EveSystem,
39 IndustryJobId,
41 ContractId,
43 PlanetId,
45 SystemId,
47 TypeId,
49 #[serde(other)]
51 Unrecognized,
52}
53
54#[derive(Debug, Clone, PartialEq, Deserialize)]
56#[allow(missing_docs)]
57pub struct JournalEntry {
58 pub amount: Option<f64>,
59 pub balance: Option<f64>,
60 pub context_id: Option<i64>,
61 pub context_id_type: Option<JournalContextType>,
62 pub date: String,
63 pub description: String,
64 pub first_party_id: Option<i64>,
65 pub id: i64,
66 pub reason: Option<String>,
67 pub ref_type: String,
70 pub second_party_id: Option<i64>,
71 pub tax: Option<f64>,
72 pub tax_receiver_id: Option<i64>,
73}
74
75impl WalletGroup<'_> {
76 api_get!(
77 get_journal,
79 "GetCharactersCharacterIdWalletJournal",
80 RequestType::Authenticated,
81 Vec<JournalEntry>,
82 (character_id: i64) => "{character_id}";
83 Optional(page: i32) => "page"
84 );
85}
86
87#[cfg(test)]
88mod character_basic_tests {
89 use super::{JournalContextType, JournalEntry};
90
91 #[test]
92 fn test_parse_journal_entries() {
93 let json = r#"[
94 {"id": 9000000000, "date": "2026-10-01T00:00:00Z", "description": "Bounty",
95 "ref_type": "bounty_prizes", "amount": 1500.5, "balance": 100.0,
96 "context_id": 30000142, "context_id_type": "system_id", "first_party_id": 2112625428},
97 {"id": 2, "date": "2026-10-01T00:00:00Z", "description": "?", "ref_type": "new_kind",
98 "context_id_type": "something_new"}
99 ]"#;
100 let entries: Vec<JournalEntry> = serde_json::from_str(json).unwrap();
101 assert_eq!(entries[0].id, 9_000_000_000);
102 assert_eq!(
103 entries[0].context_id_type,
104 Some(JournalContextType::SystemId)
105 );
106 assert_eq!(
107 entries[1].context_id_type,
108 Some(JournalContextType::Unrecognized)
109 );
110 assert!(entries[1].amount.is_none());
111 }
112}
113
114#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
116#[allow(missing_docs)]
117pub struct DivisionBalance {
118 pub balance: f64,
119 pub division: i64,
120}
121
122#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
124#[allow(missing_docs)]
125pub struct CorporationWalletTransaction {
126 pub client_id: i64,
127 pub date: String,
128 pub is_buy: bool,
129 pub journal_ref_id: i64,
130 pub location_id: i64,
131 pub quantity: i64,
132 pub transaction_id: i64,
133 pub type_id: i64,
134 pub unit_price: f64,
135}
136
137impl WalletGroup<'_> {
138 api_get!(
139 get_corporation_wallets,
141 "GetCorporationsCorporationIdWallets",
142 RequestType::Authenticated,
143 Vec<DivisionBalance>,
144 (corporation_id: i64) => "{corporation_id}"
145 );
146
147 api_get!(
148 get_corporation_journal,
150 "GetCorporationsCorporationIdWalletsDivisionJournal",
151 RequestType::Authenticated,
152 Vec<JournalEntry>,
153 (corporation_id: i64) => "{corporation_id}",
154 (division: i64) => "{division}";
155 Optional(page: i32) => "page"
156 );
157
158 api_get!(
159 get_corporation_transactions,
162 "GetCorporationsCorporationIdWalletsDivisionTransactions",
163 RequestType::Authenticated,
164 Vec<CorporationWalletTransaction>,
165 (corporation_id: i64) => "{corporation_id}",
166 (division: i64) => "{division}";
167 Optional(from_id: i64) => "from_id"
168 );
169}