use cbat::prelude::*;
#[tokio::main]
async fn main() {
let client = Client::new(
"accounts-example",
std::env::var("CBAT_KEY_NAME").expect("CBAT_KEY_NAME must be set"),
std::env::var("CBAT_KEY_SECRET").expect("CBAT_KEY_SECRET must be set"),
);
println!("=== Listing All Accounts ===");
match ApiAccounts::list_accounts(&client).await {
Ok(accounts) => println!("{:#?}", accounts),
Err(e) => eprintln!("Error listing accounts: {}", e),
}
println!("\n=== Getting Specific Account ===");
match ApiAccounts::list_accounts(&client).await {
Ok(accounts) => {
if let Some(accs) = accounts.accounts {
if let Some(first_account) = accs.first() {
match ApiAccounts::get_account(&client, &first_account.uuid).await {
Ok(account) => println!("{:#?}", account),
Err(e) => eprintln!("Error getting account: {}", e),
}
}
}
}
Err(e) => eprintln!("Error listing accounts: {}", e),
}
println!("\n=== Listing Portfolios ===");
match ApiPortfolios::list_portfolios(&client, None).await {
Ok(portfolios) => println!("{:#?}", portfolios),
Err(e) => eprintln!("Error listing portfolios: {}", e),
}
}