up-api/README.md

42 lines
1.2 KiB
Markdown
Raw Normal View History

2022-07-09 13:01:31 +00:00
# Up API
A convenient and easy to use wrapper for the [Up Bank API](https://developer.up.com.au).
2022-07-09 13:01:31 +00:00
## Example
2022-07-10 08:39:53 +00:00
The following example shows the calculation of the sum of all transactions after a given date (up to the page limit).
2022-07-09 13:01:31 +00:00
```
2022-07-10 08:39:53 +00:00
use up_api::v1::Client;
use up_api::v1::transactions::ListTransactionsOptions;
2022-07-09 13:01:31 +00:00
#[tokio::main]
async fn main() {
let token = std::env::var("UP_ACCESS_TOKEN").unwrap();
2022-07-10 08:39:53 +00:00
2022-07-09 13:01:31 +00:00
let client = Client::new(token.to_string());
let mut options = ListTransactionsOptions::default();
2022-07-10 08:39:53 +00:00
options.filter_since("2020-01-01T01:02:03Z".to_string());
options.page_size(100);
2022-07-09 13:01:31 +00:00
2022-07-10 08:39:53 +00:00
let transactions = client.list_transactions(&options).await.unwrap();
2022-07-09 13:01:31 +00:00
let total : f32 =
transactions
.data
.into_iter()
.map(|t| t.attributes.amount.value)
2022-07-10 08:39:53 +00:00
.map(|v| v.parse::<f32>().unwrap())
.filter(|a| a > &0.0)
2022-07-09 13:01:31 +00:00
.sum();
println!("{}", total);
}
```
2022-07-10 08:39:53 +00:00
## Planned Features
- Currently this API wrapper supports all of the `v1` Up API endpoints except [webhooks](https://developer.up.com.au/#webhooks). This is planned for a (hopefully soon) future release.
- Functions `prev` and `next` on the reslts of paginated endpoints are planned to make moving between pages significantly easier.