36 lines
851 B
Rust
36 lines
851 B
Rust
|
use anyhow::Result;
|
||
|
use bunq::{BunqConfig, CsvType, StatementFormat};
|
||
|
use std::time::Duration;
|
||
|
|
||
|
fn main() -> Result<()> {
|
||
|
let cfg = BunqConfig::load()?;
|
||
|
|
||
|
let client = cfg.install()?;
|
||
|
|
||
|
let accs = client.monetary_accounts()?;
|
||
|
|
||
|
let acc = &accs[0];
|
||
|
|
||
|
let stmt_id = client.request_statement(
|
||
|
acc,
|
||
|
StatementFormat::CSV(CsvType::Semicolon),
|
||
|
"2023-12-05",
|
||
|
"2023-12-15",
|
||
|
)?;
|
||
|
|
||
|
println!("Waiting for statement {:?}...", stmt_id);
|
||
|
|
||
|
let mut ready = client.is_statement_ready(acc, stmt_id)?;
|
||
|
while !ready {
|
||
|
println!("Statement is not ready yet. Waiting 5 seconds...");
|
||
|
std::thread::sleep(Duration::from_secs(5));
|
||
|
ready = client.is_statement_ready(acc, stmt_id)?;
|
||
|
}
|
||
|
|
||
|
let contents = client.download_statement(acc, stmt_id)?;
|
||
|
|
||
|
println!("{contents}");
|
||
|
|
||
|
Ok(())
|
||
|
}
|