2022-07-09 23:01:31 +10:00
|
|
|
//! # Up API
|
|
|
|
|
//!
|
2022-07-10 11:32:41 +10:00
|
|
|
//! A convenient and easy to use wrapper for the [Up Bank API](https://developer.up.com.au).
|
2022-07-10 18:39:53 +10:00
|
|
|
//!
|
|
|
|
|
//! ## Example
|
|
|
|
|
//!
|
|
|
|
|
//! The following example shows the calculation of the sum of all transactions after a given date (up to the page limit).
|
|
|
|
|
//!
|
|
|
|
|
//! ```
|
|
|
|
|
//! use up_api::v1::Client;
|
|
|
|
|
//! use up_api::v1::transactions::ListTransactionsOptions;
|
|
|
|
|
//!
|
|
|
|
|
//! #[tokio::main]
|
|
|
|
|
//! async fn main() {
|
|
|
|
|
//! let token = std::env::var("UP_ACCESS_TOKEN").unwrap();
|
|
|
|
|
//!
|
|
|
|
|
//! let client = Client::new(token.to_string());
|
|
|
|
|
//!
|
|
|
|
|
//! let mut options = ListTransactionsOptions::default();
|
|
|
|
|
//! options.filter_since("2020-01-01T01:02:03Z".to_string());
|
|
|
|
|
//! options.page_size(100);
|
|
|
|
|
//!
|
|
|
|
|
//! let transactions = client.list_transactions(&options).await.unwrap();
|
|
|
|
|
//!
|
|
|
|
|
//! let total : f32 =
|
|
|
|
|
//! transactions
|
|
|
|
|
//! .data
|
|
|
|
|
//! .into_iter()
|
|
|
|
|
//! .map(|t| t.attributes.amount.value)
|
|
|
|
|
//! .map(|v| v.parse::<f32>().unwrap())
|
|
|
|
|
//! .filter(|a| a > &0.0)
|
|
|
|
|
//! .sum();
|
|
|
|
|
//!
|
|
|
|
|
//! println!("{}", total);
|
|
|
|
|
//! }
|
|
|
|
|
//! ```
|
2022-07-09 23:01:31 +10:00
|
|
|
|
2022-07-10 11:32:41 +10:00
|
|
|
/// Module for interacting with the v1 (beta) release of the Up API.
|
|
|
|
|
pub mod v1;
|