#[cfg(feature = "api-client")]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use ib_flex::api::FlexApiClient;
use std::time::Duration;
let token = std::env::var("IB_FLEX_TOKEN")?;
let query_id = std::env::var("IB_FLEX_QUERY_ID")?;
let client = FlexApiClient::new(token);
let reference_code = client.send_request(&query_id).await?;
println!("Reference code: {}", reference_code);
tokio::time::sleep(Duration::from_secs(5)).await;
let xml = client.get_statement(&reference_code).await?;
let statement = ib_flex::parse_activity_flex(&xml)?;
println!("Account: {}", statement.account_id);
println!("Trades: {}", statement.trades.items.len());
Ok(())
}
#[cfg(not(feature = "api-client"))]
fn main() {
eprintln!("This example requires the 'api-client' feature.");
eprintln!("Run with: cargo run --example api_simple_usage --features api-client");
std::process::exit(1);
}