[−][src]Struct monzo::Client
A full-featured Monzo API client.
This client can refresh it's own access token if it expires See the individual methods for descriptions of the API endpoints.
For a full list of client functionality, see the [MonzoClient] trait
Implementations
impl Client
[src]
pub fn quick(access_token: impl Into<String>) -> QuickClient
[src]
Create a new QuickClient
. The QuickClient
can do everything that the
normal client can do, except it cannot refresh its authentication of the
access token expires (and it doesn't need the refresh token and client
credentials to construct).
This is functionally identical to calling QuickClient::new(...)
Example
let client: QuickClient = Client::quick(ACCESS_TOKEN);
pub fn new(
access_token: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
refresh_token: impl Into<String>
) -> Self
[src]
access_token: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
refresh_token: impl Into<String>
) -> Self
Create a new Client
.
In order to create a refreshable client you will need an access token, a client ID, a client secret, and a refresh token. See the Monzo API documentation for details.
It is possible to use a dummy string for the access token, provided the
other details are correct and you call
[refresh_auth](Client::refresh_auth)
before using it. In practice,
it's unlikely that you'll have refresh credentials and not also have
an access token.
pub fn from_http_client(
http_client: Client,
access_token: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
refresh_token: impl Into<String>
) -> Self
[src]
http_client: Client,
access_token: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
refresh_token: impl Into<String>
) -> Self
BYO HTTP client.
The Monzo client uses a reqwest http client under the hood. If you wish, you may use your own reqwest client with whatever configuration you see fit.
#[must_use]pub fn client_id(&self) -> &String
[src]
Get a reference to the client id in the request
#[must_use]pub fn client_secret(&self) -> &String
[src]
Get a reference to the client secret in the request
#[must_use]pub fn refresh_token(&self) -> &String
[src]
Get a reference to the refresh token in the request
pub async fn refresh_auth<'_>(&'_ mut self) -> Result<()>
[src]
Refresh the access and refresh tokens for this client
#[must_use]pub fn access_token(&self) -> &String
[src]
Return a reference to the current access token
pub async fn accounts<'_>(&'_ self) -> Result<Vec<Account>>
[src]
pub async fn balance<'_, '_>(&'_ self, account_id: &'_ str) -> Result<Balance>
[src]
pub async fn pots<'_>(&'_ self) -> Result<Vec<Pot>>
[src]
#[must_use]pub fn basic_feed_item<'a>(
&self,
account_id: &'a str,
title: &'a str,
image_url: &'a str
) -> Basic<'a>
[src]
&self,
account_id: &'a str,
title: &'a str,
image_url: &'a str
) -> Basic<'a>
Post a basic item on the account feed.
Example
use monzo::Client; 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?;
Note
At the time of writing the feed item API doesn't appear to quite match the documentation. 'image url' doesn't appear to do anything
#[must_use]pub fn deposit_into_pot(
&self,
pot_id: &str,
source_account_id: &str,
amount: i64
) -> Deposit
[src]
&self,
pot_id: &str,
source_account_id: &str,
amount: i64
) -> Deposit
Deposit money into a pot
#[must_use]pub fn transactions<'a>(&self, account_id: &'a str) -> List<'a>
[src]
Get a list of transactions
The only required field is the account id, however optional pagination parameters can be supplied.
Example
use monzo::Client; use chrono::{Duration, Utc}; 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.
#[must_use]pub fn transaction(&self, transaction_id: &str) -> Get
[src]
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.
pub fn set_access_token(&mut self, access_token: impl Into<String>)
[src]
Manually update the access token
pub fn with_access_token(self, access_token: impl Into<String>) -> Self
[src]
Builder-style method for setting the access token
#[must_use]pub fn http_client(&self) -> &Client
[src]
Return a reference to the internal http client
pub fn set_http_client(&mut self, http_client: Client)
[src]
Swap out the internal http client for your own one.
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,