shared/api/endpoints/image/recent.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//! Routes for a user's recently used images list
//! Note: this assumes that the image referred to exists or is valid.
use crate::{
api::{endpoints::ApiEndpoint, Method},
domain::image::recent::{
UserRecentImageDeletePath, UserRecentImageListPath, UserRecentImageListRequest,
UserRecentImageListResponse, UserRecentImageResponse, UserRecentImageUpsertPath,
UserRecentImageUpsertRequest,
},
error::EmptyError,
};
/// List recent images for the user.
/// Note: `limit` query is optional.
///
/// # Errors
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
///
/// * ['BadRequest'](http::StatusCode::BAD_REQUEST) if the request is malformed.
pub struct List;
impl ApiEndpoint for List {
type Path = UserRecentImageListPath;
type Req = UserRecentImageListRequest;
type Res = UserRecentImageListResponse;
type Err = EmptyError;
const METHOD: Method = Method::Get;
}
/// Update or add an entry in the list of recent user images.
/// Invoking this bumps the entry to the top of the recent images list.
///
/// # Errors
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
///
/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the image doesn't exist in the user's recent images list.
///
/// * ['BadRequest'](http::StatusCode::BAD_REQUEST) if the request is malformed.
pub struct Put;
// TODO: Move ID into request body
// TODO: grab req/res from above
impl ApiEndpoint for Put {
type Path = UserRecentImageUpsertPath;
type Req = UserRecentImageUpsertRequest;
type Res = UserRecentImageResponse;
type Err = EmptyError;
const METHOD: Method = Method::Put;
}
/// Remove an entry from the list of recent user images.
///
/// # Errors
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
///
/// * ['BadRequest'](http::StatusCode::BAD_REQUEST) if the request is malformed.
pub struct Delete;
impl ApiEndpoint for Delete {
type Path = UserRecentImageDeletePath;
type Req = ();
type Res = ();
type Err = EmptyError;
const METHOD: Method = Method::Delete;
}