Skip to main content

onesignal_rust_api/models/
journey_node.rs

1/*
2 * OneSignal
3 *
4 * A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
5 *
6 * Contact: devrel@onesignal.com
7 * Generated by: https://openapi-generator.tech
8 */
9
10/// 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.
11
12
13
14#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
15pub struct JourneyNode {
16    /// Server-assigned node UUID. Returned on reads. Required on update to keep an existing node. Rejected on create with a 400 validation error.
17    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
18    pub id: Option<String>,
19    /// Node kind. Selects which other fields apply.
20    #[serde(rename = "kind")]
21    pub kind: KindType,
22    /// 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.
23    #[serde(rename = "client_node_id", skip_serializing_if = "Option::is_none")]
24    pub client_node_id: Option<String>,
25    /// Optional free-text label, up to 255 characters. Stored and returned as-is with no effect on journey behavior.
26    #[serde(rename = "annotation", skip_serializing_if = "Option::is_none")]
27    pub annotation: Option<String>,
28    /// wait nodes: seconds to hold the user. Minimum 60, maximum 31556952 (1 year).
29    #[serde(rename = "duration_seconds", skip_serializing_if = "Option::is_none")]
30    pub duration_seconds: Option<i32>,
31    /// time_window nodes: schedule_in_timezone uses the configured windows; last_active_time holds relative to the user's last active time.
32    #[serde(rename = "relative_to", skip_serializing_if = "Option::is_none")]
33    pub relative_to: Option<RelativeToType>,
34    /// 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.
35    #[serde(rename = "windows", skip_serializing_if = "Option::is_none")]
36    pub windows: Option<Vec<crate::models::JourneyTimeWindow>>,
37    /// time_window nodes: IANA timezone identifier used when the user's timezone is unavailable.
38    #[serde(rename = "time_zone", skip_serializing_if = "Option::is_none")]
39    pub time_zone: Option<String>,
40    /// time_window nodes: when true, uses the user's timezone if available.
41    #[serde(rename = "use_user_time_zone", skip_serializing_if = "Option::is_none")]
42    pub use_user_time_zone: Option<bool>,
43    /// send_push, send_email, and send_sms nodes: UUID of the template to send.
44    #[serde(rename = "template_id", skip_serializing_if = "Option::is_none")]
45    pub template_id: Option<String>,
46    /// send_iam nodes: UUID of the in-app message to send.
47    #[serde(rename = "iam_id", skip_serializing_if = "Option::is_none")]
48    pub iam_id: Option<String>,
49    /// send_iam nodes: optional time-to-live for the in-app message, in seconds.
50    #[serde(rename = "user_ttl_seconds", skip_serializing_if = "Option::is_none")]
51    pub user_ttl_seconds: Option<i32>,
52    /// send_webhook nodes: UUID of the webhook to send.
53    #[serde(rename = "webhook_id", skip_serializing_if = "Option::is_none")]
54    pub webhook_id: Option<String>,
55    /// 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.
56    #[serde(rename = "assignments", skip_serializing_if = "Option::is_none")]
57    pub assignments: Option<::std::collections::HashMap<String, String>>,
58    /// split_range nodes: when true, assigns each user to a branch at random on entry. Defaults to false.
59    #[serde(rename = "randomize_on_entry", skip_serializing_if = "Option::is_none")]
60    pub randomize_on_entry: Option<bool>,
61    /// 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.
62    #[serde(rename = "branches", skip_serializing_if = "Option::is_none")]
63    pub branches: Option<Vec<crate::models::JourneyBranch>>,
64    #[serde(rename = "expiration", skip_serializing_if = "Option::is_none")]
65    pub expiration: Option<Box<crate::models::JourneyWaitUntilExpiration>>,
66}
67
68impl JourneyNode {
69    /// 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.
70    pub fn new(kind: KindType) -> JourneyNode {
71        JourneyNode {
72            id: None,
73            kind,
74            client_node_id: None,
75            annotation: None,
76            duration_seconds: None,
77            relative_to: None,
78            windows: None,
79            time_zone: None,
80            use_user_time_zone: None,
81            template_id: None,
82            iam_id: None,
83            user_ttl_seconds: None,
84            webhook_id: None,
85            assignments: None,
86            randomize_on_entry: None,
87            branches: None,
88            expiration: None,
89        }
90    }
91}
92
93/// Node kind. Selects which other fields apply.
94#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
95pub enum KindType {
96    #[serde(rename = "wait")]
97    Wait,
98    #[serde(rename = "time_window")]
99    TimeWindow,
100    #[serde(rename = "send_push")]
101    SendPush,
102    #[serde(rename = "send_email")]
103    SendEmail,
104    #[serde(rename = "send_sms")]
105    SendSms,
106    #[serde(rename = "send_iam")]
107    SendIam,
108    #[serde(rename = "send_webhook")]
109    SendWebhook,
110    #[serde(rename = "tag")]
111    Tag,
112    #[serde(rename = "split_range")]
113    SplitRange,
114    #[serde(rename = "yes_no")]
115    YesNo,
116    #[serde(rename = "wait_until")]
117    WaitUntil,
118}
119
120impl Default for KindType {
121    fn default() -> KindType {
122        Self::Wait
123    }
124}
125/// time_window nodes: schedule_in_timezone uses the configured windows; last_active_time holds relative to the user's last active time.
126#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
127pub enum RelativeToType {
128    #[serde(rename = "schedule_in_timezone")]
129    ScheduleInTimezone,
130    #[serde(rename = "last_active_time")]
131    LastActiveTime,
132}
133
134impl Default for RelativeToType {
135    fn default() -> RelativeToType {
136        Self::ScheduleInTimezone
137    }
138}
139