onesignal_rust_api/models/update_live_activity_request.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
11
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct UpdateLiveActivityRequest {
15 /// An internal name to assist with your campaign organization. This does not get displayed in the message itself.
16 #[serde(rename = "name")]
17 pub name: String,
18 #[serde(rename = "event")]
19 pub event: EventType,
20 /// This must match the ContentState interface you have defined within your Live Activity in your app.
21 #[serde(rename = "event_updates")]
22 pub event_updates: serde_json::Value,
23 #[serde(rename = "contents", skip_serializing_if = "Option::is_none")]
24 pub contents: Option<Box<crate::models::LanguageStringMap>>,
25 #[serde(rename = "headings", skip_serializing_if = "Option::is_none")]
26 pub headings: Option<Box<crate::models::LanguageStringMap>>,
27 /// Deprecated. The API ignores this field. Use `ios_sound`.
28 #[serde(rename = "sound", skip_serializing_if = "Option::is_none")]
29 pub sound: Option<String>,
30 /// Sound file that is included in your app to play instead of the default device notification sound. Omit to disable vibration and sound for the notification. Requires `headings` on the same request: ActivityKit ignores an update whose alert has no title, which silently drops the sound. Supersedes the deprecated `sound` field.
31 #[serde(rename = "ios_sound", skip_serializing_if = "Option::is_none")]
32 pub ios_sound: Option<String>,
33 /// Accepts Unix timestamp in seconds. When time reaches the configured stale date, the system considers the Live Activity out of date, and the ActivityState of the Live Activity changes to ActivityState.stale.
34 #[serde(rename = "stale_date", skip_serializing_if = "Option::is_none")]
35 pub stale_date: Option<i32>,
36 /// Accepts Unix timestamp in seconds; only allowed if event is \"end\"
37 #[serde(rename = "dismissal_date", skip_serializing_if = "Option::is_none")]
38 pub dismissal_date: Option<i32>,
39 /// Delivery priority through the push provider (APNs). Pass 10 for higher priority notifications, or 5 for lower priority notifications. Lower priority notifications are sent based on the power considerations of the end user's device. If not set, defaults to 10. Some providers (APNs) allow for a limited budget of high priority notifications per hour, and if that budget is exceeded, the provider may throttle notification delivery.
40 #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
41 pub priority: Option<i32>,
42 /// A value between 0 and 1. When more than one Live Activity is active for your app, the one with the highest relevance score shows in the Dynamic Island. If the scores are equal, the system shows the Live Activity that started first. The score also sets the order of Live Activities on the Lock Screen. Only available on iOS 16.2 and later.
43 #[serde(rename = "ios_relevance_score", skip_serializing_if = "Option::is_none")]
44 pub ios_relevance_score: Option<f32>,
45}
46
47impl UpdateLiveActivityRequest {
48 pub fn new(name: String, event: EventType, event_updates: serde_json::Value) -> UpdateLiveActivityRequest {
49 UpdateLiveActivityRequest {
50 name,
51 event,
52 event_updates,
53 contents: None,
54 headings: None,
55 sound: None,
56 ios_sound: None,
57 stale_date: None,
58 dismissal_date: None,
59 priority: None,
60 ios_relevance_score: None,
61 }
62 }
63}
64
65///
66#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
67pub enum EventType {
68 #[serde(rename = "update")]
69 Update,
70 #[serde(rename = "end")]
71 End,
72}
73
74impl Default for EventType {
75 fn default() -> EventType {
76 Self::Update
77 }
78}
79