onesignal-rust-api 5.12.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
 */

/// JourneyNode : A journey node. The kind field selects which other fields apply. Branching nodes (split_range, yes_no, wait_until) nest their sub-graphs inline via branches[].nodes.



#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct JourneyNode {
    /// Server-assigned node UUID. Returned on reads. Required on update to keep an existing node. Rejected on create with a 400 validation error.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// Node kind. Selects which other fields apply.
    #[serde(rename = "kind")]
    pub kind: KindType,
    /// Optional client-assigned identifier, unique within the journey. Use it to reference this node from elsewhere in the same request. Persisted and returned on reads.
    #[serde(rename = "client_node_id", skip_serializing_if = "Option::is_none")]
    pub client_node_id: Option<String>,
    /// Optional free-text label, up to 255 characters. Stored and returned as-is with no effect on journey behavior.
    #[serde(rename = "annotation", skip_serializing_if = "Option::is_none")]
    pub annotation: Option<String>,
    /// wait nodes: seconds to hold the user. Minimum 60, maximum 31556952 (1 year).
    #[serde(rename = "duration_seconds", skip_serializing_if = "Option::is_none")]
    pub duration_seconds: Option<i32>,
    /// time_window nodes: schedule_in_timezone uses the configured windows; last_active_time holds relative to the user's last active time.
    #[serde(rename = "relative_to", skip_serializing_if = "Option::is_none")]
    pub relative_to: Option<RelativeToType>,
    /// time_window nodes: one or more time windows. A window with no day_of_week applies to every day. Required when relative_to is schedule_in_timezone; omit when it is last_active_time.
    #[serde(rename = "windows", skip_serializing_if = "Option::is_none")]
    pub windows: Option<Vec<crate::models::JourneyTimeWindow>>,
    /// time_window nodes: IANA timezone identifier used when the user's timezone is unavailable.
    #[serde(rename = "time_zone", skip_serializing_if = "Option::is_none")]
    pub time_zone: Option<String>,
    /// time_window nodes: when true, uses the user's timezone if available.
    #[serde(rename = "use_user_time_zone", skip_serializing_if = "Option::is_none")]
    pub use_user_time_zone: Option<bool>,
    /// send_push, send_email, and send_sms nodes: UUID of the template to send.
    #[serde(rename = "template_id", skip_serializing_if = "Option::is_none")]
    pub template_id: Option<String>,
    /// send_iam nodes: UUID of the in-app message to send.
    #[serde(rename = "iam_id", skip_serializing_if = "Option::is_none")]
    pub iam_id: Option<String>,
    /// send_iam nodes: optional time-to-live for the in-app message, in seconds.
    #[serde(rename = "user_ttl_seconds", skip_serializing_if = "Option::is_none")]
    pub user_ttl_seconds: Option<i32>,
    /// send_webhook nodes: UUID of the webhook to send.
    #[serde(rename = "webhook_id", skip_serializing_if = "Option::is_none")]
    pub webhook_id: Option<String>,
    /// tag nodes: tag key-value pairs to assign. An empty string value removes the tag. Keys are limited to 255 characters and values to 1024.
    #[serde(rename = "assignments", skip_serializing_if = "Option::is_none")]
    pub assignments: Option<::std::collections::HashMap<String, String>>,
    /// split_range nodes: when true, assigns each user to a branch at random on entry. Defaults to false.
    #[serde(rename = "randomize_on_entry", skip_serializing_if = "Option::is_none")]
    pub randomize_on_entry: Option<bool>,
    /// Branching nodes: nested branches. split_range requires 2-20 weighted branches that sum to 100. yes_no requires exactly 2 branches. wait_until requires 1-10 condition branches.
    #[serde(rename = "branches", skip_serializing_if = "Option::is_none")]
    pub branches: Option<Vec<crate::models::JourneyBranch>>,
    #[serde(rename = "expiration", skip_serializing_if = "Option::is_none")]
    pub expiration: Option<Box<crate::models::JourneyWaitUntilExpiration>>,
}

impl JourneyNode {
    /// A journey node. The kind field selects which other fields apply. Branching nodes (split_range, yes_no, wait_until) nest their sub-graphs inline via branches[].nodes.
    pub fn new(kind: KindType) -> JourneyNode {
        JourneyNode {
            id: None,
            kind,
            client_node_id: None,
            annotation: None,
            duration_seconds: None,
            relative_to: None,
            windows: None,
            time_zone: None,
            use_user_time_zone: None,
            template_id: None,
            iam_id: None,
            user_ttl_seconds: None,
            webhook_id: None,
            assignments: None,
            randomize_on_entry: None,
            branches: None,
            expiration: None,
        }
    }
}

/// Node kind. Selects which other fields apply.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum KindType {
    #[serde(rename = "wait")]
    Wait,
    #[serde(rename = "time_window")]
    TimeWindow,
    #[serde(rename = "send_push")]
    SendPush,
    #[serde(rename = "send_email")]
    SendEmail,
    #[serde(rename = "send_sms")]
    SendSms,
    #[serde(rename = "send_iam")]
    SendIam,
    #[serde(rename = "send_webhook")]
    SendWebhook,
    #[serde(rename = "tag")]
    Tag,
    #[serde(rename = "split_range")]
    SplitRange,
    #[serde(rename = "yes_no")]
    YesNo,
    #[serde(rename = "wait_until")]
    WaitUntil,
}

impl Default for KindType {
    fn default() -> KindType {
        Self::Wait
    }
}
/// time_window nodes: schedule_in_timezone uses the configured windows; last_active_time holds relative to the user's last active time.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum RelativeToType {
    #[serde(rename = "schedule_in_timezone")]
    ScheduleInTimezone,
    #[serde(rename = "last_active_time")]
    LastActiveTime,
}

impl Default for RelativeToType {
    fn default() -> RelativeToType {
        Self::ScheduleInTimezone
    }
}