pinterest_api/parameter/
metric_type.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use serde::{Deserialize, Serialize};
use std::fmt;

#[derive(Debug, Clone)]
pub enum MetricTypes {
    Standard(Vec<StandardMetricType>),
    Video(Vec<VideoMetricType>),
}

impl Default for MetricTypes {
    fn default() -> Self {
        Self::Standard(vec![])
    }
}

impl std::fmt::Display for MetricTypes {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let result = match self {
            Self::Standard(metric_types) => metric_types
                .iter()
                .map(|metric_type| metric_type.to_string())
                .collect::<Vec<String>>()
                .join(","),
            Self::Video(metric_types) => metric_types
                .iter()
                .map(|metric_type| metric_type.to_string())
                .collect::<Vec<String>>()
                .join(","),
        };
        write!(f, "{}", result)
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum StandardMetricType {
    Impression,
    OutboundClick,
    PinClick,
    Save,
    SaveRate,
    TotalComments,
    TotalReactions,
    UserFollow,
    ProfileVisit,
}

impl fmt::Display for StandardMetricType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::Impression => write!(f, "IMPRESSION"),
            Self::OutboundClick => write!(f, "OUTBOUND_CLICK"),
            Self::PinClick => write!(f, "PIN_CLICK"),
            Self::Save => write!(f, "SAVE"),
            Self::SaveRate => write!(f, "SAVE_RATE"),
            Self::TotalComments => write!(f, "TOTAL_COMMENTS"),
            Self::TotalReactions => write!(f, "TOTAL_REACTIONS"),
            Self::UserFollow => write!(f, "USER_FOLLOW"),
            Self::ProfileVisit => write!(f, "PROFILE_VISIT"),
        }
    }
}

impl Default for StandardMetricType {
    fn default() -> Self {
        Self::Impression
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum VideoMetricType {
    Impression,
    OutboundClick,
    PinClick,
    Save,
    SaveRate,
    VideoMrcView,
    Video10sView,
    Quartile95PercentView,
    VideoV50WatchTime,
    VideoStart,
    VideoAvgWatchTime,
    TotalComments,
    TotalReactions,
}

impl fmt::Display for VideoMetricType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::Impression => write!(f, "IMPRESSION"),
            Self::OutboundClick => write!(f, "OUTBOUND_CLICK"),
            Self::PinClick => write!(f, "PIN_CLICK"),
            Self::Save => write!(f, "SAVE"),
            Self::SaveRate => write!(f, "SAVE_RATE"),
            Self::VideoMrcView => write!(f, "VIDEO_MRC_VIEW"),
            Self::Video10sView => write!(f, "VIDEO_10S_VIEW"),
            Self::Quartile95PercentView => write!(f, "QUARTILE_95_PERCENT_VIEW"),
            Self::VideoV50WatchTime => write!(f, "VIDEO_V50_WATCH_TIME"),
            Self::VideoStart => write!(f, "VIDEO_START"),
            Self::VideoAvgWatchTime => write!(f, "VIDEO_AVG_WATCH_TIME"),
            Self::TotalComments => write!(f, "TOTAL_COMMENTS"),
            Self::TotalReactions => write!(f, "TOTAL_REACTIONS"),
        }
    }
}

impl Default for VideoMetricType {
    fn default() -> Self {
        Self::Impression
    }
}