pushover_rs/pushover/data/message.rs
1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
4/**
5A message to be used in conjunction with the send_pushover_request function.
6
7Note: It is preferred to create a Message through the MessageBuilder.
8 **/
9pub struct Message {
10 /* Required */
11 /// (Required) Your app API token, see https://pushover.net/apps/[your application ID]
12 #[serde(rename = "token")]
13 pub app_token: String,
14 /// (Required) Your User key, see your dashboard (https://pushover.net/ top-right)
15 #[serde(rename = "user")]
16 pub user_key: String,
17 /// (Required) Your message
18 pub message: String,
19
20 /* Optional */
21 /// The title of the message, otherwise your app's name will be used
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub title: Option<String>,
24 /// A supplementary URL to show with your message
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub url: Option<String>,
27 /// A title for your supplementary URL, otherwise just the URL is shown
28 #[serde(skip_serializing_if = "Option::is_none")]
29 pub url_title: Option<String>,
30 /// Send as -2 to generate no notification/alert, -1 to always send as a quiet notification, 1 to display as high-priority and bypass the user's quiet hours, or 2 to also require confirmation from the user
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub priority: Option<i8>,
33 /// When the priority is set to 2, sets the amount of seconds between each retries. Must be at least 30 seconds.
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub retry: Option<i32>, // Required if priority is set to 2
36 /// When the priority is set to 2, sets the amount of seconds before the notification is expired. The maximum value is 10800 (3 hours).be between 60 and 10800.
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub expire: Option<i32>, // Required if priority is set to 2
39 /// The name of one of the sounds supported by device clients to override the user's default sound choice. (See sound list: https://pushover.net/api#sounds)
40 #[serde(skip_serializing_if = "Option::is_none")]
41 pub sound: Option<String>,
42 /// A Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API
43 #[serde(skip_serializing_if = "Option::is_none")]
44 pub timestamp: Option<u64>, // Year 2038 proof :p
45 /// A device name to send the push notifications to, if you want to limit the notification to a certain device.
46 #[serde(skip_serializing_if = "Option::is_none")]
47 pub device: Option<String>,
48 /// A TTL (Time to Live) in seconds, after which the message will be automatically deleted from the recipient's inbox.
49 /// Setting *ttl* to None prevents this auto removal. Setting TTL to 0 will raise an error (ttl must be > 0).
50 #[serde(skip_serializing_if = "Option::is_none")]
51 pub ttl: Option<u32>,
52}
53
54impl Default for Message {
55 fn default() -> Self {
56 Self {
57 app_token: "".into(),
58 user_key: "".into(),
59 message: "No message set.".into(),
60 title: None,
61 url: None,
62 url_title: None,
63 priority: None,
64 retry: None,
65 expire: None,
66 sound: None,
67 timestamp: None,
68 device: None,
69 ttl: None,
70 }
71 }
72}