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
/*
* 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: 5.3.0
* Contact: devrel@onesignal.com
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct FilterExpression {
/// Required. Name of the field to use as the first operand in the filter expression.
#[serde(rename = "field", skip_serializing_if = "Option::is_none")]
pub field: Option<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>,
/// If `field` is session-related, this is *required* to specify the number of hours before or after the user's session.
#[serde(rename = "hours_ago", skip_serializing_if = "Option::is_none")]
pub hours_ago: Option<String>,
/// If `field` is `location`, this will specify the radius in meters from a provided location point. Use with `lat` and `long`.
#[serde(rename = "radius", skip_serializing_if = "Option::is_none")]
pub radius: Option<f32>,
/// If `field` is `location`, this is *required* to specify the user's latitude.
#[serde(rename = "lat", skip_serializing_if = "Option::is_none")]
pub lat: Option<f32>,
/// If `field` is `location`, this is *required* to specify the user's longitude.
#[serde(rename = "long", skip_serializing_if = "Option::is_none")]
pub long: Option<f32>,
/// Required. Operator of a filter expression.
#[serde(rename = "relation", skip_serializing_if = "Option::is_none")]
pub relation: Option<RelationType>,
/// Strictly, this must be either `\"OR\"`, or `\"AND\"`. It can be used to compose Filters as part of a Filters object.
#[serde(rename = "operator", skip_serializing_if = "Option::is_none")]
pub operator: Option<OperatorType>,
}
impl FilterExpression {
pub fn new() -> FilterExpression {
FilterExpression {
field: None,
key: None,
value: None,
hours_ago: None,
radius: None,
lat: None,
long: None,
relation: None,
operator: None,
}
}
}
/// Required. 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
}
}
/// Strictly, this must be either `\"OR\"`, or `\"AND\"`. It can be used to compose Filters as part of a Filters object.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OperatorType {
#[serde(rename = "OR")]
OR,
#[serde(rename = "AND")]
AND,
}
impl Default for OperatorType {
fn default() -> OperatorType {
Self::OR
}
}