pinterest_api/response/
board.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap as Map;
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
6pub enum Privacy {
7    Protected,
8    Public,
9    Secret,
10}
11
12// Privacyの表示を設定
13impl std::fmt::Display for Privacy {
14    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
15        match self {
16            Self::Protected => write!(f, "PROTECTED"),
17            Self::Public => write!(f, "PUBLIC"),
18            Self::Secret => write!(f, "SECRET"),
19        }
20    }
21}
22
23// Privacyのデフォルト値を設定
24impl Default for Privacy {
25    fn default() -> Self {
26        Self::Public
27    }
28}
29
30#[derive(Serialize, Deserialize, Debug, Clone, Default)]
31pub struct Board {
32    pub id: String,
33    pub created_at: String,
34    pub board_pins_modified_at: String,
35    pub name: String,
36    pub description: Option<String>,
37    pub collaborator_count: i64,
38    pub pin_count: i64,
39    pub follower_count: i64,
40    pub media: BoardMedia,
41    pub owner: Owner,
42    pub privacy: Privacy,
43
44    #[serde(flatten, skip_serializing_if = "Map::is_empty")]
45    pub extra: Map<String, serde_json::Value>,
46}
47
48#[derive(Serialize, Deserialize, Debug, Clone, Default)]
49pub struct BoardMedia {
50    pub image_cover_url: Option<String>,
51    pub pin_thumbnail_urls: Vec<String>,
52
53    #[serde(flatten, skip_serializing_if = "Map::is_empty")]
54    pub extra: Map<String, serde_json::Value>,
55}
56
57#[derive(Serialize, Deserialize, Debug, Clone, Default)]
58pub struct Owner {
59    pub username: String,
60
61    #[serde(flatten, skip_serializing_if = "Map::is_empty")]
62    pub extra: Map<String, serde_json::Value>,
63}