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
/*
 * OneSignal
 *
 * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
 *
 * The version of the OpenAPI document: 1.0.1
 * Contact: devrel@onesignal.com
 * Generated by: https://openapi-generator.tech
 */




#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct Filter {
    /// Name of the field to use as the first operand in the filter expression.
    #[serde(rename = "field")]
    pub field: String,
    /// If `field` is `tag`, this field is *required* to specify `key` inside the tags.
    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
    pub key: Option<String>,
    /// Constant value to use as the second operand in the filter expression.  This value is *required* when the relation operator is a binary operator.
    #[serde(rename = "value", skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    /// Operator of a filter expression.
    #[serde(rename = "relation")]
    pub relation: RelationType,
}

impl Filter {
    pub fn new(field: String, relation: RelationType) -> Filter {
        Filter {
            field,
            key: None,
            value: None,
            relation,
        }
    }
}

/// Operator of a filter expression.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum RelationType {
    #[serde(rename = ">")]
    Greater_Than,
    #[serde(rename = "<")]
    Less_Than,
    #[serde(rename = "=")]
    Equal,
    #[serde(rename = "!=")]
    Not_Equal,
    #[serde(rename = "exists")]
    Exists,
    #[serde(rename = "not_exists")]
    NotExists,
    #[serde(rename = "time_elapsed_gt")]
    TimeElapsedGt,
    #[serde(rename = "time_elapsed_lt")]
    TimeElapsedLt,
}

impl Default for RelationType {
    fn default() -> RelationType {
        Self::Greater_Than
    }
}