onesignal-rust-api 5.3.0

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
Documentation
/*
 * 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
    }
}