Struct tripactions::Client
source · pub struct Client { /* private fields */ }
Expand description
Entrypoint for interacting with the API client.
Implementations§
source§impl Client
impl Client
sourcepub fn new<I, K, T>(client_id: I, client_secret: K, token: T) -> Selfwhere
I: ToString,
K: ToString,
T: ToString,
pub fn new<I, K, T>(client_id: I, client_secret: K, token: T) -> Selfwhere I: ToString, K: ToString, T: ToString,
Create a new Client struct. Requires OAuth2 configuration values as well as an access token.
Panics
This function will panic if the internal http client fails to create
sourcepub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere
H: ToString,
pub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere H: ToString,
Override the host for all endpoins in the client.
sourcepub fn remove_host_override(&mut self) -> &mut Self
pub fn remove_host_override(&mut self) -> &mut Self
Disables the global host override for the client.
pub fn get_host_override(&self) -> Option<&str>
sourcepub fn new_from_env<T>(token: T) -> Selfwhere
T: ToString,
pub fn new_from_env<T>(token: T) -> Selfwhere T: ToString,
Create a new Client struct from environment variables.
The following environment variables are expected to be set:
TRIPACTIONS_CLIENT_ID
TRIPACTIONS_CLIENT_SECRET
Panics
This function will panic if the expected environment variables can not be found
sourcepub async fn get_access_token(&mut self) -> Result<AccessToken, ClientError>
pub async fn get_access_token(&mut self) -> Result<AccessToken, ClientError>
Get an access token from the code returned by the URL paramter sent to the redirect URL.
pub fn booking_data(&self) -> BookingData
Trait Implementations§
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more