pub struct ApiClient { /* private fields */ }Implementations§
Source§impl ApiClient
impl ApiClient
pub fn new(base_url: String, token: Option<String>) -> Result<Self>
pub fn set_token(&mut self, token: String)
Sourcepub async fn login(
&self,
username: &str,
password: &str,
) -> Result<LoginResponse>
pub async fn login( &self, username: &str, password: &str, ) -> Result<LoginResponse>
Login to the platform
Sourcepub async fn verify_token(&self) -> Result<bool>
pub async fn verify_token(&self) -> Result<bool>
Verify if the token is still valid
Sourcepub async fn get<T: DeserializeOwned>(
&self,
path: &str,
query: &[(&str, String)],
) -> Result<T>
pub async fn get<T: DeserializeOwned>( &self, path: &str, query: &[(&str, String)], ) -> Result<T>
Generic GET request
Sourcepub async fn post<T: DeserializeOwned>(
&self,
path: &str,
body: &Value,
) -> Result<T>
pub async fn post<T: DeserializeOwned>( &self, path: &str, body: &Value, ) -> Result<T>
Generic POST request
Sourcepub async fn patch<T: DeserializeOwned>(
&self,
path: &str,
body: &Value,
) -> Result<T>
pub async fn patch<T: DeserializeOwned>( &self, path: &str, body: &Value, ) -> Result<T>
Generic PATCH request
Sourcepub async fn delete<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn delete<T: DeserializeOwned>(&self, path: &str) -> Result<T>
Generic DELETE request
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl UnsafeUnpin for ApiClient
impl !UnwindSafe for ApiClient
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