shared/domain/image/
user.rs

1//! Types for user image library.
2
3use crate::api::endpoints::PathPart;
4use macros::make_path_parts;
5use serde::{Deserialize, Serialize};
6
7use super::{ImageId, ImageSize};
8
9make_path_parts!(UserImageGetPath => "/v1/user/me/image/{}" => ImageId);
10
11make_path_parts!(UserImageCreatePath => "/v1/user/me/image");
12
13/// Request for creating a user image profile
14#[derive(Serialize, Deserialize, Debug)]
15pub struct UserImageCreateRequest {
16    /// The size of the image. Most relevant for uploading user profile images
17    pub size: ImageSize,
18}
19
20make_path_parts!(UserImageListPath => "/v1/user/me/image");
21
22/// Query for listing. This is optional. If used, should be included as part of the query string.
23///
24/// * `kind` field must match the case as represented in the returned json body (`PascalCase`?).
25#[derive(Serialize, Deserialize, Debug)]
26pub struct UserImageListQuery {
27    /// Optionally filter by image kind. If included it will only return results of the corresponding
28    /// kinds listed.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub kind: Option<ImageSize>,
31}
32
33/// Response for listing.
34#[derive(Serialize, Deserialize, Debug)]
35pub struct UserImageListResponse {
36    /// the images returned.
37    pub images: Vec<UserImageResponse>,
38}
39
40/// Response for getting a single image.
41#[derive(Serialize, Deserialize, Debug)]
42pub struct UserImageResponse {
43    /// The image metadata.
44    pub metadata: UserImage,
45}
46
47/// Over the wire representation of an image's metadata.
48#[derive(Serialize, Deserialize, Debug)]
49pub struct UserImage {
50    /// The image's ID.
51    pub id: ImageId,
52    /// The image size
53    pub size: ImageSize,
54    // more fields to be added
55}
56
57make_path_parts!(UserImageUploadPath => "/v1/user/me/image/{}/raw" => ImageId);
58
59/// Request to indicate the size of an user library image for upload.
60#[derive(Serialize, Deserialize, Debug)]
61pub struct UserImageUploadRequest {
62    /// The size of the image to be uploaded in bytes.
63    pub file_size: usize,
64}
65
66/// URL to upload an user library image, supports resumable uploading.
67#[derive(Serialize, Deserialize, Debug)]
68pub struct UserImageUploadResponse {
69    /// The session URI used for uploading, including the query for uploader ID
70    pub session_uri: String,
71}
72
73make_path_parts!(UserImageDeletePath => "/v1/user/me/image/{}" => ImageId);