monzo/lib.rs
1#![deny(
2 clippy::all,
3 missing_debug_implementations,
4 missing_copy_implementations,
5 missing_docs,
6 clippy::cargo
7)]
8#![warn(clippy::pedantic)]
9#![allow(clippy::missing_errors_doc)]
10
11//! A Monzo client in pure rust.
12//!
13//! It's ergonomic, strongly-typed, and asynchronous.
14//!
15//!
16//! In order to use this client, you will first need to get an access token and/or refresh token for the Monzo API (see [the docs](https://docs.monzo.com/))
17//!
18//! ## Usage
19//! ```no_run
20//! use monzo::Client;
21//!
22//! #[tokio::main]
23//! async fn main() -> monzo::Result<()> {
24//! // You can create a simple monzo client using only an access token
25//! let quick_client = Client::new("ACCESS_TOKEN");
26//!
27//! // get a list of accounts
28//! let accounts = quick_client.accounts().await?;
29//!
30//! // get the id of one of the accounts
31//! let account_id = &accounts[0].id;
32//!
33//! // get the balance of that account
34//! let balance = quick_client.balance(account_id).await?;
35//!
36//! // If you have a refresh token and client credentials
37//! // you can create or upgrade a client which is capable
38//! // of refreshing its own access token.
39//! let mut refreshable_client =
40//! quick_client.with_refresh_tokens("CLIENT_ID", "CLIENT_SECRET", "REFRESH_TOKEN");
41//!
42//! refreshable_client.refresh_auth().await?;
43//!
44//! Ok(())
45//! }
46//! ```
47
48#[cfg(doctest)]
49doc_comment::doctest!("../README.md");
50
51mod client;
52#[doc(inline)]
53pub use client::Client;
54mod endpoints;
55#[doc(inline)]
56pub use endpoints::accounts::{Account, Owner};
57pub use endpoints::{
58 accounts, balance::Balance, feed_items, pots::Pot, transactions, transactions::Transaction,
59 who_am_i::Response as WhoAmI,
60};
61mod error;
62pub use client::inner as inner_client;
63pub use error::Error;
64
65/// Result type for all methods in this crate which can fail.
66pub type Result<T> = std::result::Result<T, Error>;