[][src]Struct monzo::client::QuickClient

#[must_use]pub struct QuickClient { /* fields omitted */ }

A quick and dirty Monzo API client.

This client is easy to construct, because all you need is an access token. This client is not capable of refreshing the access token, hence this must be managed externally.

For a full list of client functionality, see the [MonzoClient] trait

Implementations

impl Client[src]

pub fn new(access_token: impl Into<String>) -> Self[src]

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.

pub fn from_http_client(
    http_client: Client,
    access_token: impl Into<String>
) -> Self
[src]

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.

pub fn with_refresh_tokens(
    self,
    client_id: impl Into<String>,
    client_secret: impl Into<String>,
    refresh_token: impl Into<String>
) -> RefreshableClient
[src]

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.

#[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]

Return a list of accounts

Example

let accounts = client.accounts().await?;

pub async fn balance<'_, '_>(&'_ self, account_id: &'_ str) -> Result<Balance>[src]

Return the balance of a given account

Example

let balance = client.balance(ACCOUNT_ID).await?;

pub async fn pots<'_>(&'_ self) -> Result<Vec<Pot>>[src]

Return a list of Pots

Example

let pots = client.pots().await?;

#[must_use]pub fn basic_feed_item<'a>(
    &self,
    account_id: &'a str,
    title: &'a str,
    image_url: &'a str
) -> Basic<'a>
[src]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,