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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//! Integration tests for FLEX Web Service API client
//!
//! Note: Most tests are unit tests in src/api/client.rs
//! These integration tests verify the public API surface.
use ;
// Note: The following tests are commented out because they require actual IB credentials
// and a live FLEX query. To run these tests, uncomment and provide your credentials.
/*
#[test]
#[ignore] // Ignored by default - requires real IB credentials
fn test_send_request_integration() {
// Set these environment variables to run this test:
// - IB_FLEX_TOKEN: Your FLEX Web Service token
// - IB_FLEX_QUERY_ID: Your FLEX query ID
let token = std::env::var("IB_FLEX_TOKEN").expect("IB_FLEX_TOKEN not set");
let query_id = std::env::var("IB_FLEX_QUERY_ID").expect("IB_FLEX_QUERY_ID not set");
let client = FlexApiClient::new(token);
let result = client.send_request(&query_id);
match result {
Ok(ref_code) => {
println!("Reference code: {}", ref_code);
assert!(!ref_code.is_empty());
}
Err(e) => panic!("Send request failed: {:?}", e),
}
}
#[test]
#[ignore] // Ignored by default - requires real IB credentials
fn test_get_statement_integration() {
use std::time::Duration;
let token = std::env::var("IB_FLEX_TOKEN").expect("IB_FLEX_TOKEN not set");
let query_id = std::env::var("IB_FLEX_QUERY_ID").expect("IB_FLEX_QUERY_ID not set");
let client = FlexApiClient::new(token);
// Step 1: Send request
let ref_code = client.send_request(&query_id)
.expect("Failed to send request");
println!("Reference code: {}", ref_code);
// Step 2: Wait for statement generation
std::thread::sleep(Duration::from_secs(5));
// Step 3: Get statement with retry
let xml = client.get_statement_with_retry(&ref_code, 10, Duration::from_secs(2))
.expect("Failed to get statement");
assert!(!xml.is_empty());
assert!(xml.contains("<?xml"));
println!("Received XML ({} bytes)", xml.len());
}
#[test]
#[ignore] // Ignored by default - requires real IB credentials
fn test_full_workflow_integration() {
use std::time::Duration;
let token = std::env::var("IB_FLEX_TOKEN").expect("IB_FLEX_TOKEN not set");
let query_id = std::env::var("IB_FLEX_QUERY_ID").expect("IB_FLEX_QUERY_ID not set");
let client = FlexApiClient::new(token);
// Step 1: Send request
let ref_code = client.send_request(&query_id)
.expect("Failed to send request");
// Step 2: Get statement with retry
let xml = client.get_statement_with_retry(&ref_code, 10, Duration::from_secs(2))
.expect("Failed to get statement");
// Step 3: Parse the statement
let statement = ib_flex::parse_activity_flex(&xml)
.expect("Failed to parse statement");
println!("Account: {}", statement.account_id);
println!("Trades: {}", statement.trades.items.len());
assert!(!statement.account_id.is_empty());
}
*/