shared/api/endpoints/user/profile.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 67 68 69 70
use crate::{
api::{ApiEndpoint, Method},
domain::{
session::NewSessionResponse,
user::{
CreateProfilePath, CreateProfileRequest, GetProfilePath, PatchProfileAdminDataPath,
PatchProfileAdminDataRequest, PatchProfilePath, PatchProfileRequest, UserProfile,
},
},
error::EmptyError,
};
/// Fetch your own user profile.
pub struct Get;
impl ApiEndpoint for Get {
type Path = GetProfilePath;
type Req = ();
type Res = UserProfile;
type Err = EmptyError;
const METHOD: Method = Method::Get;
}
/// Create or replace a user profile.
///
/// # Flow
/// *
/// *
///
/// # Errors
/// * Invalid request - [`400 - Bad Request`](http::StatusCode::BAD_REQUEST)
/// * Missing / bad auth - [`401 - Unauthorized`](http::StatusCode::UNAUTHORIZED)
/// * User not found - [`404 - Not Found`](http::StatusCode::NOT_FOUND)
/// * Profile image with ID not found - [`404 - Not Found`](http::StatusCode::NOT_FOUND)
/// * Taken username - [`409 - Conflict`](http::StatusCode::CONFLICT)
/// * Empty username - [`422 - Unprocessable Entity`](http::StatusCode::UNPROCESSABLE_ENTITY)
pub struct Create;
impl ApiEndpoint for Create {
type Path = CreateProfilePath;
type Req = CreateProfileRequest;
type Res = NewSessionResponse;
type Err = EmptyError;
const METHOD: Method = Method::Post;
}
/// Update a user profile.
///
/// # Errors
///
/// * Invalid request - [`400 - Bad Request`](http::StatusCode::BAD_REQUEST)
/// * Missing / bad auth - [`401 - Unauthorized`](http::StatusCode::UNAUTHORIZED)
/// * Taken username - [`409 - Conflict`](http::StatusCode::CONFLICT)
/// * Empty username - [`422 - Unprocessable Entity`](http::StatusCode::UNPROCESSABLE_ENTITY)
pub struct Patch;
impl ApiEndpoint for Patch {
type Path = PatchProfilePath;
type Req = PatchProfileRequest;
type Res = ();
type Err = EmptyError;
const METHOD: Method = Method::Patch;
}
/// Update a user profile data that only an admin can update. E.g. badge.
pub struct PatchProfileAdminData;
impl ApiEndpoint for PatchProfileAdminData {
type Path = PatchProfileAdminDataPath;
type Req = PatchProfileAdminDataRequest;
type Res = ();
type Err = EmptyError;
const METHOD: Method = Method::Patch;
}