pub struct Client<C>where
C: Inner,{ /* private fields */ }
Expand description
A Monzo API client
Implementations§
Source§impl Client<Quick>
impl Client<Quick>
Sourcepub fn new(access_token: impl Into<String>) -> Self
pub fn new(access_token: impl Into<String>) -> Self
Create a new Monzo Client..
This Client
needs only an access token to authenticate against
the Monzo API, but is incapable of refreshing its access if the
token expires.
Sourcepub fn with_refresh_tokens(
self,
client_id: impl Into<String>,
client_secret: impl Into<String>,
refresh_token: impl Into<String>,
) -> Client<Refreshable>
pub fn with_refresh_tokens( self, client_id: impl Into<String>, client_secret: impl Into<String>, refresh_token: impl Into<String>, ) -> Client<Refreshable>
Upgrade a Client by adding refresh tokens.
A client that has refresh tokens is able to refresh it’s authentication when the access token expires.
Source§impl Client<Refreshable>
impl Client<Refreshable>
Sourcepub const fn client_secret(&self) -> &String
pub const fn client_secret(&self) -> &String
Get a reference to the client secret
Sourcepub const fn refresh_token(&self) -> &String
pub const fn refresh_token(&self) -> &String
Get a reference to the refresh token
Sourcepub async fn refresh_auth(&mut self) -> Result<i64>
pub async fn refresh_auth(&mut self) -> Result<i64>
Refresh the access and refresh tokens for this client
Returns the time (in seconds) until the token expires
Source§impl<C> Client<C>where
C: Inner,
impl<C> Client<C>where
C: Inner,
Sourcepub fn access_token(&self) -> &String
pub fn access_token(&self) -> &String
Return a reference to the current access token
Sourcepub fn set_access_token(&mut self, access_token: impl Into<String>)
pub fn set_access_token(&mut self, access_token: impl Into<String>)
Manually update the access token
Sourcepub const fn basic_feed_item<'a>(
&'a self,
account_id: &'a str,
title: &'a str,
image_url: &'a str,
) -> Request<'a, C>
pub const fn basic_feed_item<'a>( &'a self, account_id: &'a str, title: &'a str, image_url: &'a str, ) -> Request<'a, C>
Post a basic item on the account feed.
§Example
let account_id = "ACCOUNT_ID";
let title = "Feed Item Title";
let image_url = "http://www.nyan.cat/cats/original.gif";
client
.basic_feed_item(account_id, title, image_url)
.body("i figured out how to send messages to monzo from my computer...")
.send()
.await?;
Sourcepub async fn deposit_into_pot(
&self,
pot_id: &str,
source_account_id: &str,
amount: u32,
) -> Result<Pot>
pub async fn deposit_into_pot( &self, pot_id: &str, source_account_id: &str, amount: u32, ) -> Result<Pot>
Deposit money into a pot
Sourcepub async fn withdraw_from_pot(
&self,
pot_id: &str,
destination_account_id: &str,
amount: u32,
) -> Result<Pot>
pub async fn withdraw_from_pot( &self, pot_id: &str, destination_account_id: &str, amount: u32, ) -> Result<Pot>
Withdraw money from a pot
Sourcepub fn transactions<'a>(&'a self, account_id: &'a str) -> List<'a, C>
pub fn transactions<'a>(&'a self, account_id: &'a str) -> List<'a, C>
Get a list of transactions
The only required field is the account id, however optional pagination parameters can be supplied.
§Example
use chrono::{Duration, Utc};
use monzo::Client;
let account_id = "ACCOUNT_ID";
let transactions = client
.transactions(account_id)
.since(Utc::now() - Duration::days(10))
.limit(10)
.send()
.await?;
§Note
The Monzo API will only return transactions from more than 90 days ago in the first 5 minutes after authorising the Client. You can avoid this by using the ‘since’ method.
Sourcepub fn transaction<'a>(&'a self, transaction_id: &'a str) -> Get<'a, C>
pub fn transaction<'a>(&'a self, transaction_id: &'a str) -> Get<'a, C>
Retrieve a transaction by transaction id
§Example
use monzo::Client;
let transaction_id = "TRANSACTION_ID";
let transactions = client.transaction(transaction_id).send().await?;
§Note
The Monzo API will only return transactions from more than 90 days ago in the first 5 minutes after authorising the Client.