monzo/endpoints/
balance.rs

1//! Acount balance
2
3use serde::Deserialize;
4
5/// The balance of a Monzo Account
6#[derive(Deserialize, Debug)]
7#[must_use]
8pub struct Balance {
9    /// The account balance, in the minor units of the listed currency. ie for
10    /// GBP, the balance is in pence.
11    pub balance: i64,
12
13    /// The total account balance. I haven't figured out what the difference is
14    /// yet
15    pub total_balance: i64,
16
17    /// three-letter currency code for the account
18    pub currency: String,
19
20    /// total expenditure so far this calendar day
21    pub spend_today: i64,
22}
23
24pub use get::Request as Get;
25mod get {
26    use serde::Serialize;
27
28    use crate::endpoints::Endpoint;
29
30    /// An object representing a request to the Monzo API for a list of accounts
31    pub struct Request<'a> {
32        query: Query<'a>,
33    }
34
35    impl<'a> Request<'a> {
36        pub(crate) const fn new(account_id: &'a str) -> Self {
37            let query = Query { account_id };
38            Self { query }
39        }
40    }
41
42    impl Endpoint for Request<'_> {
43        const METHOD: reqwest::Method = reqwest::Method::GET;
44
45        fn endpoint(&self) -> &'static str {
46            "/balance"
47        }
48
49        fn query(&self) -> Option<&dyn erased_serde::Serialize> {
50            Some(&self.query)
51        }
52    }
53
54    #[derive(Debug, Serialize)]
55    struct Query<'a> {
56        account_id: &'a str,
57    }
58}