dummy_json_rs

Struct DummyJsonClient

Source
pub struct DummyJsonClient {
    pub client: Client,
}

Fields§

§client: Client

Implementations§

Source§

impl DummyJsonClient

Source

pub async fn login( &self, username: &str, password: &str, expires_in_mins: Option<u32>, ) -> Result<LoginResponse, Error>

Login to the dummyjson API

Source

pub async fn get_user(&self, access_token: &str) -> Result<User, Error>

Get the current user

Source

pub async fn refresh_auth_session( &self, refresh_token: &str, expires_in_mins: u32, ) -> Result<RefreshResponse, Error>

Refresh the auth session

Source§

impl DummyJsonClient

Source

pub async fn get_all_carts(&self) -> Result<GetAllCartsResponse, Error>

Get all carts

Source

pub async fn get_cart_by_id(&self, id: u32) -> Result<Cart, Error>

Get cart by id

Source

pub async fn get_carts_of_user( &self, user_id: u32, ) -> Result<GetAllCartsResponse, Error>

Get carts of user

Source

pub async fn add_cart(&self, payload: AddCartPayload) -> Result<Cart, Error>

Add cart

Source

pub async fn update_cart( &self, id: u32, payload: UpdateCartPayload, ) -> Result<Cart, Error>

Update cart

Source

pub async fn delete_cart( &self, cart_id: u32, ) -> Result<DeleteCartResponse, Error>

Delete cart

Source§

impl DummyJsonClient

Source

pub async fn get_all_comments(&self) -> Result<GetAllComments, Error>

Get all comments

Source

pub async fn get_comment_by_id(&self, id: u32) -> Result<Comment, Error>

Get comment by id

Source

pub async fn limit_and_skip_comments( &self, limit: u32, skip: u32, select: &str, ) -> Result<GetAllComments, Error>

Limit and skip comments

Source

pub async fn get_comments_by_post_id( &self, post_id: u32, ) -> Result<GetAllComments, Error>

Get comments by post id

Source

pub async fn add_comment(&self, comment: &AddComment) -> Result<Comment, Error>

Add comment

Source

pub async fn update_comment( &self, id: u32, body: &str, ) -> Result<Comment, Error>

Update comment

Source

pub async fn delete_comment( &self, id: u32, ) -> Result<DeleteCommentResponse, Error>

Delete comment

Source§

impl DummyJsonClient

Source

pub async fn get_all_posts(&self) -> Result<GetAllPosts, Error>

Get all posts

Source

pub async fn get_post_by_id(&self, id: u32) -> Result<Post, Error>

Get post by id

Source

pub async fn search_posts(&self, query: &str) -> Result<GetAllPosts, Error>

Search posts

Source

pub async fn limit_and_skip_posts( &self, limit: u32, skip: u32, selects: &str, ) -> Result<GetAllPosts, Error>

Limit and skip posts

Source

pub async fn sort_posts( &self, sort_by: &str, order: &str, ) -> Result<GetAllPosts, Error>

Sort posts

Source

pub async fn get_all_posts_tags(&self) -> Result<Vec<ProductCategory>, Error>

Get all posts tags

Source

pub async fn get_posts_by_tags(&self, tag: &str) -> Result<GetAllPosts, Error>

Get posts by tags

Source

pub async fn get_posts_by_user_id( &self, user_id: u32, ) -> Result<GetAllPosts, Error>

Get posts by user id

Source

pub async fn get_post_comments( &self, id: u32, ) -> Result<PostCommentsResponse, Error>

Get post comments

Source

pub async fn add_post(&self, post: &AddPost) -> Result<Post, Error>

Add post

Source

pub async fn update_post( &self, id: u32, post: &AddPost, ) -> Result<AddPost, Error>

Update post

Source

pub async fn delete_post(&self, id: u32) -> Result<Post, Error>

Delete post

Source§

impl DummyJsonClient

Source

pub async fn get_all_products(&self) -> Result<GetAllProductsResponse, Error>

Get all products

Source

pub async fn get_product_by_id(&self, id: u32) -> Result<Product, Error>

Get product by id

Source

pub async fn search_products( &self, query: &str, ) -> Result<GetAllProductsResponse, Error>

Search products

Source

pub async fn limit_and_skip_products( &self, limit: u32, skip: u32, selects: &str, ) -> Result<GetAllProductsResponse, Error>

Limit and skip products

Source

pub async fn sort_products_by( &self, field: &str, order: &str, ) -> Result<GetAllProductsResponse, Error>

Sort products by field

Source

pub async fn get_product_categories( &self, ) -> Result<Vec<ProductCategory>, Error>

Get product categories

Source

pub async fn get_product_categories_list(&self) -> Result<Vec<String>, Error>

Get product categories list

Source

pub async fn get_products_by_category( &self, category: &str, ) -> Result<GetAllProductsResponse, Error>

Get products by category

Source

pub async fn add_product(&self, product: &AddProduct) -> Result<Product, Error>

Add product

Source

pub async fn update_product( &self, id: u32, product: &AddProduct, ) -> Result<Product, Error>

Update product

Source

pub async fn delete_product( &self, id: u32, ) -> Result<DeleteProductResponse, Error>

Delete product

Source§

impl DummyJsonClient

Source

pub async fn get_all_quotes(&self) -> Result<GetAllQuotes, Error>

Get all quotes

Source

pub async fn get_quote_by_id(&self, id: u32) -> Result<Quote, Error>

Get quote by id

Source

pub async fn get_random_quote(&self) -> Result<Quote, Error>

Get random quote

Source

pub async fn get_random_quotes(&self, count: u32) -> Result<Vec<Quote>, Error>

Get random quotes

Source

pub async fn limit_skip_quotes( &self, limit: u32, skip: u32, ) -> Result<GetAllQuotes, Error>

Limit and skip quotes

Source§

impl DummyJsonClient

Source

pub async fn get_all_recipes(&self) -> Result<GetAllRecipesResponse, Error>

Get all recipes

Source

pub async fn get_recipe_by_id(&self, id: u32) -> Result<Recipe, Error>

Get recipe by id

Source

pub async fn search_recipes( &self, query: &str, ) -> Result<GetAllRecipesResponse, Error>

Search recipes

Source

pub async fn limit_and_skip_recipes( &self, limit: u32, skip: u32, selects: &str, ) -> Result<GetAllRecipesResponse, Error>

Limit and skip recipes

Source

pub async fn sort_recipes( &self, sort_by: &str, order: &str, ) -> Result<GetAllRecipesResponse, Error>

Sort recipes

Source

pub async fn get_recipes_tags(&self) -> Result<Vec<String>, Error>

Get recipes tags

Source

pub async fn get_recipes_by_tags( &self, tags: &str, ) -> Result<GetAllRecipesResponse, Error>

Get recipes by tags

Source

pub async fn get_recipes_by_meal_type( &self, meal_type: &str, ) -> Result<GetAllRecipesResponse, Error>

Get recipes by meal type

Source§

impl DummyJsonClient

Source

pub async fn get_all_todos(&self) -> Result<AllTodos, Error>

Get all todos

Source

pub async fn get_todo_by_id(&self, id: u32) -> Result<Todo, Error>

Get todo by id

Source

pub async fn get_random_todo(&self) -> Result<Todo, Error>

Get random todo

Source

pub async fn get_random_todos(&self, count: u32) -> Result<Vec<Todo>, Error>

Get random todos

Source

pub async fn limit_skip_todos( &self, limit: u32, skip: u32, ) -> Result<AllTodos, Error>

Limit and skip todos

Source

pub async fn get_all_todos_of_user( &self, user_id: u32, ) -> Result<AllTodos, Error>

Get all todos of user

Source

pub async fn add_todo( &self, todo: &str, completed: bool, user_id: u32, ) -> Result<Todo, Error>

Add todo

Source

pub async fn update_todo(&self, id: u32, completed: bool) -> Result<Todo, Error>

Update todo

Source

pub async fn delete_todo(&self, id: u32) -> Result<DeleteTodoResponse, Error>

Delete todo

Source§

impl DummyJsonClient

Source

pub async fn get_all_users(&self) -> Result<GetAllUsersResponse, Error>

Get all users

Source

pub async fn login_user( &self, username: &str, password: &str, expires_in_mins: Option<u32>, ) -> Result<LoginResponse, Error>

Login User and get tokens

Source

pub async fn get_current_authenticated_user( &self, access_token: &str, ) -> Result<User, Error>

Get current authenticated user

Source

pub async fn get_user_by_id(&self, id: u32) -> Result<User, Error>

Get user by id

Source

pub async fn search_users( &self, query: &str, ) -> Result<GetAllUsersResponse, Error>

Search users with name

Source

pub async fn filter_users( &self, key: &str, value: &str, ) -> Result<GetAllUsersResponse, Error>

Filter users by key and value

Source

pub async fn limit_skip_select_users( &self, limit: u32, skip: u32, selects: &str, ) -> Result<GetAllUsersResponse, Error>

Limit, skip and select users

Source

pub async fn sort_users( &self, key: &str, order: &str, ) -> Result<GetAllUsersResponse, Error>

Sort users by key and order

Source

pub async fn get_user_carts_by_user_id( &self, user_id: u32, ) -> Result<GetAllCartsResponse, Error>

Get user carts by user id

Source

pub async fn get_user_posts_by_user_id( &self, user_id: u32, ) -> Result<GetAllPosts, Error>

Get user posts by user id

Source

pub async fn get_user_todos_by_user_id( &self, user_id: u32, ) -> Result<AllTodos, Error>

Get user todos by user id

Source

pub async fn add_user(&self, user: &AddUserPayload) -> Result<User, Error>

Add user

Source

pub async fn update_user( &self, id: u32, user: &AddUserPayload, ) -> Result<User, Error>

Update user

Source

pub async fn delete_user(&self, id: u32) -> Result<DeleteUserResponse, Error>

Delete user

Trait Implementations§

Source§

impl Default for DummyJsonClient

Source§

fn default() -> DummyJsonClient

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more