onesignal-rust-api 5.14.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
 *
 * Contact: devrel@onesignal.com
 * Generated by: https://openapi-generator.tech
 */

/// JourneyCondition : A branch condition. The kind field selects which other fields apply.



#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct JourneyCondition {
    /// Condition kind. Selects which other fields apply.
    #[serde(rename = "kind")]
    pub kind: KindType,
    /// segment_membership conditions: Segment UUIDs the user must belong to.
    #[serde(rename = "included_segment_ids", skip_serializing_if = "Option::is_none")]
    pub included_segment_ids: Option<Vec<String>>,
    /// segment_membership conditions: Segment UUIDs the user must not belong to.
    #[serde(rename = "excluded_segment_ids", skip_serializing_if = "Option::is_none")]
    pub excluded_segment_ids: Option<Vec<String>>,
    /// on_notification_action conditions: the notification action to branch on. Which actions apply depends on the sending node's channel.
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<ActionType>,
    /// on_notification_action conditions: id of the sending node this action refers to. Returned on reads; accepted on write.
    #[serde(rename = "sending_node_id", skip_serializing_if = "Option::is_none")]
    pub sending_node_id: Option<String>,
    /// on_notification_action conditions: write-only alternative to sending_node_id. References the sending node by its client_node_id.
    #[serde(rename = "client_node_id", skip_serializing_if = "Option::is_none")]
    pub client_node_id: Option<String>,
    /// event_trigger conditions: event name, up to 255 characters.
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Event attribute matchers, as a list of condition groups. Send a single group whose conditions are AND'd together. More than one group is rejected.
    #[serde(rename = "attributes", skip_serializing_if = "Option::is_none")]
    pub attributes: Option<Vec<Vec<crate::models::JourneyEventAttribute>>>,
    /// event_trigger conditions: match incoming event properties against the journey's entry event. Only valid on event-triggered journeys.
    #[serde(rename = "entry_event_match_attributes", skip_serializing_if = "Option::is_none")]
    pub entry_event_match_attributes: Option<Vec<serde_json::Value>>,
}

impl JourneyCondition {
    /// A branch condition. The kind field selects which other fields apply.
    pub fn new(kind: KindType) -> JourneyCondition {
        JourneyCondition {
            kind,
            included_segment_ids: None,
            excluded_segment_ids: None,
            action: None,
            sending_node_id: None,
            client_node_id: None,
            name: None,
            attributes: None,
            entry_event_match_attributes: None,
        }
    }
}

/// Condition kind. Selects which other fields apply.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum KindType {
    #[serde(rename = "segment_membership")]
    SegmentMembership,
    #[serde(rename = "on_notification_action")]
    OnNotificationAction,
    #[serde(rename = "event_trigger")]
    EventTrigger,
}

impl Default for KindType {
    fn default() -> KindType {
        Self::SegmentMembership
    }
}
/// on_notification_action conditions: the notification action to branch on. Which actions apply depends on the sending node's channel.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ActionType {
    #[serde(rename = "received")]
    Received,
    #[serde(rename = "clicked")]
    Clicked,
    #[serde(rename = "opened")]
    Opened,
}

impl Default for ActionType {
    fn default() -> ActionType {
        Self::Received
    }
}