pinterest_api/response/
media_response.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
71
72
73
74
75
76
77
78
79
80
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum MediaType {
    Video,
}

impl std::fmt::Display for MediaType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::Video => write!(f, "video"),
        }
    }
}

impl Default for MediaType {
    fn default() -> Self {
        Self::Video
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "lowercase")]
pub enum Status {
    Registered,
    Processing,
    Succeeded,
    Failed,
}

impl std::fmt::Display for Status {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::Registered => write!(f, "registered"),
            Self::Processing => write!(f, "processing"),
            Self::Succeeded => write!(f, "succeeded"),
            Self::Failed => write!(f, "failed"),
        }
    }
}

impl Default for Status {
    fn default() -> Self {
        Self::Registered
    }
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct UploadParameters {
    #[serde(rename = "x-amz-date")]
    pub x_amz_date: String,
    #[serde(rename = "x-amz-signature")]
    pub x_amz_signature: String,
    #[serde(rename = "x-amz-security-token")]
    pub x_amz_security_token: String,
    #[serde(rename = "x-amz-algorithm")]
    pub x_amz_algorithm: String,
    pub key: String,
    pub policy: String,
    #[serde(rename = "x-amz-credential")]
    pub x_amz_credential: String,
    #[serde(rename = "Content-Type")]
    pub content_type: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MediaGetResponse {
    pub media_id: String,
    pub media_type: MediaType,
    pub status: Status,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MediaPostResponse {
    pub media_id: String,
    pub media_type: MediaType,
    pub upload_url: Status,
    pub upload_parameters: UploadParameters,
}