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