pinterest_api/response/
board.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
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Privacy {
    Protected,
    Public,
    Secret,
}

// Privacyの表示を設定
impl std::fmt::Display for Privacy {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::Protected => write!(f, "PROTECTED"),
            Self::Public => write!(f, "PUBLIC"),
            Self::Secret => write!(f, "SECRET"),
        }
    }
}

// Privacyのデフォルト値を設定
impl Default for Privacy {
    fn default() -> Self {
        Self::Public
    }
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct Board {
    id: String,
    created_at: String,
    board_pins_modified_at: String,
    name: String,
    description: Option<String>,
    collaborator_count: i64,
    pin_count: i64,
    follower_count: i64,
    media: BoardMedia,
    owner: Owner,
    privacy: Privacy,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct BoardMedia {
    image_cover_url: Option<String>,
    pin_thumbnail_urls: Vec<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct Owner {
    username: String,
}