shared/api/endpoints/image/
recent.rs

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