1 module fcm.FCMRequest;
2 
3 import std.typecons;
4 
5 import vibe.data.json;
6 
7 /**
8  * Targets, options, and payload for downstream HTTP messages (JSON).
9  * 
10  * https://firebase.google.com/docs/cloud-messaging/http-server-ref#table1
11  */
12 struct FCMRequest
13 {
14 	// Targets
15 	
16 	/**
17 	 * This parameter specifies the recipient of a message.
18 	 * 
19 	 * The value must be a registration token, notification key, or
20 	 * topic. Do not set this field when sending to multiple topics.
21 	 * See condition.
22 	 */
23 	//@optional
24 	//@name("to")
25 	//Nullable!string to;
26 	
27 	/**
28 	 * This parameter specifies a list of devices (registration tokens,
29 	 * or IDs) receiving a multicast message. It must contain at least
30 	 * 1 and at most 1000 registration tokens.
31 	 * 
32 	 * Use this parameter only for multicast messaging, not for single
33 	 * recipients. Multicast messages (sending to more than 1
34 	 * registration tokens) are allowed using HTTP JSON format only.
35 	 */
36 	@name("registration_ids")
37 	string[] registrationIds;
38 
39 	/**
40 	 * This parameter specifies a logical expression of conditions that
41 	 * determine the message target.
42 	 * 
43 	 * Supported condition: Topic, formatted as "'yourTopic' in topics".
44 	 * This value is case-insensitive.
45 	 * 
46 	 * Supported operators: &&, ||. Maximum two operators per topic
47 	 * message supported.
48 	 */
49 	//@optional
50 	//@name("condition")
51 	//Nullable!string condition;
52 
53 	/**
54 	 * This parameter is deprecated. Instead, use to to specify message
55 	 * recipients. For more information on how to send messages to
56 	 * multiple devices, see the documentation for your platform.
57 	 */
58 	//@optional
59 	//@name("notification_key")
60 	//deprecated Nullable!string notificationKey;
61 
62 	// Options
63 	
64 	/**
65 	 * This parameter identifies a group of messages (e.g., with
66 	 * collapse_key: "Updates Available") that can be collapsed, so
67 	 * that only the last message gets sent when delivery can be
68 	 * resumed. This is intended to avoid sending too many of the
69 	 * same messages when the device comes back online or becomes
70 	 * active.
71 	 * 
72 	 * Note that there is no guarantee of the order in which messages
73 	 * get sent.
74 	 * 
75 	 * Note: A maximum of 4 different collapse keys is allowed at
76 	 * any given time. This means a FCM connection server can
77 	 * simultaneously store 4 different send-to-sync messages per
78 	 * client app. If you exceed this number, there is no guarantee
79 	 * which 4 collapse keys the FCM connection server will keep.
80 	 */
81 	//@optional
82 	//@name("collapse_key")
83 	//Nullable!string collapseKey;
84 
85 	/**
86 	 * Sets the priority of the message. Valid values are "normal"
87 	 * and "high." On iOS, these correspond to APNs priorities 5 and 10.
88 	 * 
89 	 * By default, notification messages are sent with high priority,
90 	 * and data messages are sent with normal priority. Normal priority
91 	 * optimizes the client app's battery consumption and should be
92 	 * used unless immediate delivery is required. For messages with
93 	 * normal priority, the app may receive the message with
94 	 * unspecified delay.
95 	 * 
96 	 * When a message is sent with high priority, it is sent
97 	 * immediately, and the app can wake a sleeping device and open a
98 	 * network connection to your server.
99 	 * 
100 	 * For more information, see Setting the priority of a message.
101 	 * 
102 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message
103 	 */
104 	//@optional
105 	//@name("priority")
106 	//Nullable!string priority;
107 	
108 	/**
109 	 * On iOS, use this field to represent content-available in the
110 	 * APNs payload. When a notification or message is sent and this
111 	 * is set to true, an inactive client app is awoken. On Android,
112 	 * data messages wake the app by default. On Chrome, currently not
113 	 * supported.
114 	 */
115 	//@optional
116 	//@name("content_available")
117 	//Nullable!bool contentAvailable;
118 	
119 	/**
120 	 * This parameter specifies how long (in seconds) the message
121 	 * should be kept in FCM storage if the device is offline. The
122 	 * maximum time to live supported is 4 weeks, and the default
123 	 * value is 4 weeks. For more information, see Setting the
124 	 * lifespan of a message.
125 	 * 
126 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
127 	 */
128 	//@optional
129 	//@name("time_to_live")
130 	//Nullable!int timeToLive;
131 	
132 	/**
133 	 * This parameter specifies the package name of the application
134 	 * where the registration tokens must match in order to receive
135 	 * the message.
136 	 */
137 	//@optional
138 	//@name("restricted_package_name")
139 	//Nullable!string restrictedPackageName;
140 	
141 	/**
142 	 * This parameter, when set to true, allows developers to test a
143 	 * request without actually sending a message.
144 	 * 
145 	 * The default value is false.
146 	 */
147 	//@optional
148 	//@name("dry_run")
149 	//Nullable!bool dryRun;
150 	
151 	// Payload
152 
153 	/**
154 	 * This parameter specifies the custom key-value pairs of the
155 	 * message's payload.
156 	 * 
157 	 * For example, with data:{"score":"3x1"}:
158 	 * 
159 	 * On iOS, if the message is sent via APNS, it represents the
160 	 * custom data fields. If it is sent via FCM connection server,
161 	 * it would be represented as key value dictionary in AppDelegate
162 	 * application:didReceiveRemoteNotification:.
163 	 * 
164 	 * On Android, this would result in an intent extra named score
165 	 * with the string value 3x1.
166 	 * 
167 	 * The key should not be a reserved word ("from" or any word
168 	 * starting with "google" or "gcm"). Do not use any of the words
169 	 * defined in this table (such as collapse_key).
170 	 * 
171 	 * Values in string types are recommended. You have to convert
172 	 * values in objects or other non-string data types (e.g.,
173 	 * integers or booleans) to string.
174 	 */
175 	@optional
176 	@name("data")
177 	Nullable!Json data;
178 
179 	/**
180 	 * This parameter specifies the predefined, user-visible key-value
181 	 * pairs of the notification payload. See Notification payload
182 	 * support for detail. For more information about notification
183 	 * message and data message options, see Payload:
184 	 * https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
185 	 */
186 	//@optional
187 	//@name("notification")
188 	//Nullable!Json notification;
189 }