Skip to main content

onesignal_rust_api/models/
notification_target.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 * The version of the OpenAPI document: 5.6.0
7 * Contact: devrel@onesignal.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
15pub struct NotificationTarget {
16    /// The segment names you want to target. Users in these segments will receive a notification. This targeting parameter is only compatible with excluded_segments. Example: [\"Active Users\", \"Inactive Users\"] 
17    #[serde(rename = "included_segments", skip_serializing_if = "Option::is_none")]
18    pub included_segments: Option<Vec<String>>,
19    /// Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments. This targeting parameter is only compatible with included_segments. Example: [\"Active Users\", \"Inactive Users\"] 
20    #[serde(rename = "excluded_segments", skip_serializing_if = "Option::is_none")]
21    pub excluded_segments: Option<Vec<String>>,
22    /// Specific subscription ids to send your notification to. _Does not require API Auth Key._ Not compatible with any other targeting parameters. Example: [\"1dd608f2-c6a1-11e3-851d-000c2940e62c\"] Limit of 2,000 entries per REST API call 
23    #[serde(rename = "include_subscription_ids", skip_serializing_if = "Option::is_none")]
24    pub include_subscription_ids: Option<Vec<String>>,
25    /// Deprecated alias for `email_to`. Target specific email addresses. If an email does not correspond to an existing user, a new user will be created. Example: nick@catfac.ts. Limit of 2,000 entries per REST API call. Prefer `email_to` in new integrations. 
26    #[serde(rename = "include_email_tokens", skip_serializing_if = "Option::is_none")]
27    pub include_email_tokens: Option<Vec<String>>,
28    /// Recommended for Sending Emails - Target specific email addresses. If an email does not correspond to an existing user, a new user will be created. Example: nick@catfac.ts. Limit of 2,000 entries per REST API call. Supersedes the deprecated `include_email_tokens` field. 
29    #[serde(rename = "email_to", skip_serializing_if = "Option::is_none")]
30    pub email_to: Option<Vec<String>>,
31    /// Recommended for Sending SMS - Target specific phone numbers. The phone number should be in the E.164 format. Phone number should be an existing subscriber on OneSignal. Refer our docs to learn how to add phone numbers to OneSignal. Example phone number: +1999999999 Limit of 2,000 entries per REST API call 
32    #[serde(rename = "include_phone_numbers", skip_serializing_if = "Option::is_none")]
33    pub include_phone_numbers: Option<Vec<String>>,
34    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using iOS device tokens. Warning: Only works with Production tokens. All non-alphanumeric characters must be removed from each token. If a token does not correspond to an existing user, a new user will be created. Example: ce777617da7f548fe7a9ab6febb56cf39fba6d38203... Limit of 2,000 entries per REST API call 
35    #[serde(rename = "include_ios_tokens", skip_serializing_if = "Option::is_none")]
36    pub include_ios_tokens: Option<Vec<String>>,
37    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using Windows URIs. If a token does not correspond to an existing user, a new user will be created. Example: http://s.notify.live.net/u/1/bn1/HmQAAACPaLDr-... Limit of 2,000 entries per REST API call 
38    #[serde(rename = "include_wp_wns_uris", skip_serializing_if = "Option::is_none")]
39    pub include_wp_wns_uris: Option<Vec<String>>,
40    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using Amazon ADM registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: amzn1.adm-registration.v1.XpvSSUk0Rc3hTVVV... Limit of 2,000 entries per REST API call 
41    #[serde(rename = "include_amazon_reg_ids", skip_serializing_if = "Option::is_none")]
42    pub include_amazon_reg_ids: Option<Vec<String>>,
43    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using Chrome App registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call 
44    #[serde(rename = "include_chrome_reg_ids", skip_serializing_if = "Option::is_none")]
45    pub include_chrome_reg_ids: Option<Vec<String>>,
46    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using Chrome Web Push registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call 
47    #[serde(rename = "include_chrome_web_reg_ids", skip_serializing_if = "Option::is_none")]
48    pub include_chrome_web_reg_ids: Option<Vec<String>>,
49    /// Not Recommended: Please consider using include_subscription_ids or include_aliases instead. Target using Android device registration IDs. If a token does not correspond to an existing user, a new user will be created. Example: APA91bEeiUeSukAAUdnw3O2RB45FWlSpgJ7Ji_... Limit of 2,000 entries per REST API call 
50    #[serde(rename = "include_android_reg_ids", skip_serializing_if = "Option::is_none")]
51    pub include_android_reg_ids: Option<Vec<String>>,
52    /// Target specific users by aliases assigned via API. An alias can be an external_id, onesignal_id, or a custom alias. Accepts an object where keys are alias labels and values are arrays of alias IDs to include Example usage: { \"external_id\": [\"exId1\", \"extId2\"], \"internal_label\": [\"id1\", \"id2\"] } Keys must match API spellings exactly (for example the label for External ID is the string `external_id`; arbitrary keys such as camelCase variants are not aliases and may yield no recipients). Not compatible with any other targeting parameters. REQUIRED: REST API Key Authentication Limit of 2,000 entries per REST API call Note: If targeting push, email, or sms subscribers with same ids, use with target_channel to indicate you are sending a push or email or sms.
53    #[serde(rename = "include_aliases", skip_serializing_if = "Option::is_none")]
54    pub include_aliases: Option<::std::collections::HashMap<String, Vec<String>>>,
55    #[serde(rename = "target_channel", skip_serializing_if = "Option::is_none")]
56    pub target_channel: Option<TargetChannelType>,
57}
58
59impl NotificationTarget {
60    pub fn new() -> NotificationTarget {
61        NotificationTarget {
62            included_segments: None,
63            excluded_segments: None,
64            include_subscription_ids: None,
65            include_email_tokens: None,
66            email_to: None,
67            include_phone_numbers: None,
68            include_ios_tokens: None,
69            include_wp_wns_uris: None,
70            include_amazon_reg_ids: None,
71            include_chrome_reg_ids: None,
72            include_chrome_web_reg_ids: None,
73            include_android_reg_ids: None,
74            include_aliases: None,
75            target_channel: None,
76        }
77    }
78}
79
80/// 
81#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
82pub enum TargetChannelType {
83    #[serde(rename = "push")]
84    Push,
85    #[serde(rename = "email")]
86    Email,
87    #[serde(rename = "sms")]
88    Sms,
89}
90
91impl Default for TargetChannelType {
92    fn default() -> TargetChannelType {
93        Self::Push
94    }
95}
96