1/******************************************************************************
2 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3 */
4
5#pragma once
6
7#include <Quotient/csapi/definitions/push_condition.h>
8#include <Quotient/csapi/definitions/push_rule.h>
9#include <Quotient/csapi/definitions/push_ruleset.h>
10
11#include <Quotient/jobs/basejob.h>
12
13namespace Quotient {
14
15/*! \brief Retrieve all push rulesets.
16 *
17 * Retrieve all push rulesets for this user. Clients can "drill-down" on
18 * the rulesets by suffixing a `scope` to this path e.g.
19 * `/pushrules/global/`. This will return a subset of this data under the
20 * specified key e.g. the `global` key.
21 */
22class QUOTIENT_API GetPushRulesJob : public BaseJob {
23public:
24 /// Retrieve all push rulesets.
25 explicit GetPushRulesJob();
26
27 /*! \brief Construct a URL without creating a full-fledged job object
28 *
29 * This function can be used when a URL for GetPushRulesJob
30 * is necessary but the job itself isn't.
31 */
32 static QUrl makeRequestUrl(QUrl baseUrl);
33
34 // Result properties
35
36 /// The global ruleset.
37 PushRuleset global() const
38 {
39 return loadFromJson<PushRuleset>(keyName: "global"_ls);
40 }
41};
42
43/*! \brief Retrieve a push rule.
44 *
45 * Retrieve a single specified push rule.
46 */
47class QUOTIENT_API GetPushRuleJob : public BaseJob {
48public:
49 /*! \brief Retrieve a push rule.
50 *
51 * \param scope
52 * `global` to specify global rules.
53 *
54 * \param kind
55 * The kind of rule
56 *
57 * \param ruleId
58 * The identifier for the rule.
59 */
60 explicit GetPushRuleJob(const QString& scope, const QString& kind,
61 const QString& ruleId);
62
63 /*! \brief Construct a URL without creating a full-fledged job object
64 *
65 * This function can be used when a URL for GetPushRuleJob
66 * is necessary but the job itself isn't.
67 */
68 static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope,
69 const QString& kind, const QString& ruleId);
70
71 // Result properties
72
73 /// The specific push rule. This will also include keys specific to the
74 /// rule itself such as the rule's `actions` and `conditions` if set.
75 PushRule pushRule() const { return fromJson<PushRule>(json: jsonData()); }
76};
77
78/*! \brief Delete a push rule.
79 *
80 * This endpoint removes the push rule defined in the path.
81 */
82class QUOTIENT_API DeletePushRuleJob : public BaseJob {
83public:
84 /*! \brief Delete a push rule.
85 *
86 * \param scope
87 * `global` to specify global rules.
88 *
89 * \param kind
90 * The kind of rule
91 *
92 * \param ruleId
93 * The identifier for the rule.
94 */
95 explicit DeletePushRuleJob(const QString& scope, const QString& kind,
96 const QString& ruleId);
97
98 /*! \brief Construct a URL without creating a full-fledged job object
99 *
100 * This function can be used when a URL for DeletePushRuleJob
101 * is necessary but the job itself isn't.
102 */
103 static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope,
104 const QString& kind, const QString& ruleId);
105};
106
107/*! \brief Add or change a push rule.
108 *
109 * This endpoint allows the creation and modification of user defined push
110 * rules.
111 *
112 * If a rule with the same `rule_id` already exists among rules of the same
113 * kind, it is updated with the new parameters, otherwise a new rule is
114 * created.
115 *
116 * If both `after` and `before` are provided, the new or updated rule must
117 * be the next most important rule with respect to the rule identified by
118 * `before`.
119 *
120 * If neither `after` nor `before` are provided and the rule is created, it
121 * should be added as the most important user defined rule among rules of
122 * the same kind.
123 *
124 * When creating push rules, they MUST be enabled by default.
125 */
126class QUOTIENT_API SetPushRuleJob : public BaseJob {
127public:
128 /*! \brief Add or change a push rule.
129 *
130 * \param scope
131 * `global` to specify global rules.
132 *
133 * \param kind
134 * The kind of rule
135 *
136 * \param ruleId
137 * The identifier for the rule. If the string starts with a dot ("."),
138 * the request MUST be rejected as this is reserved for server-default
139 * rules. Slashes ("/") and backslashes ("\\") are also not allowed.
140 *
141 * \param actions
142 * The action(s) to perform when the conditions for this rule are met.
143 *
144 * \param before
145 * Use 'before' with a `rule_id` as its value to make the new rule the
146 * next-most important rule with respect to the given user defined rule.
147 * It is not possible to add a rule relative to a predefined server rule.
148 *
149 * \param after
150 * This makes the new rule the next-less important rule relative to the
151 * given user defined rule. It is not possible to add a rule relative
152 * to a predefined server rule.
153 *
154 * \param conditions
155 * The conditions that must hold true for an event in order for a
156 * rule to be applied to an event. A rule with no conditions
157 * always matches. Only applicable to `underride` and `override` rules.
158 *
159 * \param pattern
160 * Only applicable to `content` rules. The glob-style pattern to match
161 * against.
162 */
163 explicit SetPushRuleJob(const QString& scope, const QString& kind,
164 const QString& ruleId,
165 const QVector<QVariant>& actions,
166 const QString& before = {},
167 const QString& after = {},
168 const QVector<PushCondition>& conditions = {},
169 const QString& pattern = {});
170};
171
172/*! \brief Get whether a push rule is enabled
173 *
174 * This endpoint gets whether the specified push rule is enabled.
175 */
176class QUOTIENT_API IsPushRuleEnabledJob : public BaseJob {
177public:
178 /*! \brief Get whether a push rule is enabled
179 *
180 * \param scope
181 * Either `global` or `device/<profile_tag>` to specify global
182 * rules or device rules for the given `profile_tag`.
183 *
184 * \param kind
185 * The kind of rule
186 *
187 * \param ruleId
188 * The identifier for the rule.
189 */
190 explicit IsPushRuleEnabledJob(const QString& scope, const QString& kind,
191 const QString& ruleId);
192
193 /*! \brief Construct a URL without creating a full-fledged job object
194 *
195 * This function can be used when a URL for IsPushRuleEnabledJob
196 * is necessary but the job itself isn't.
197 */
198 static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope,
199 const QString& kind, const QString& ruleId);
200
201 // Result properties
202
203 /// Whether the push rule is enabled or not.
204 bool enabled() const { return loadFromJson<bool>(keyName: "enabled"_ls); }
205};
206
207/*! \brief Enable or disable a push rule.
208 *
209 * This endpoint allows clients to enable or disable the specified push rule.
210 */
211class QUOTIENT_API SetPushRuleEnabledJob : public BaseJob {
212public:
213 /*! \brief Enable or disable a push rule.
214 *
215 * \param scope
216 * `global` to specify global rules.
217 *
218 * \param kind
219 * The kind of rule
220 *
221 * \param ruleId
222 * The identifier for the rule.
223 *
224 * \param enabled
225 * Whether the push rule is enabled or not.
226 */
227 explicit SetPushRuleEnabledJob(const QString& scope, const QString& kind,
228 const QString& ruleId, bool enabled);
229};
230
231/*! \brief The actions for a push rule
232 *
233 * This endpoint get the actions for the specified push rule.
234 */
235class QUOTIENT_API GetPushRuleActionsJob : public BaseJob {
236public:
237 /*! \brief The actions for a push rule
238 *
239 * \param scope
240 * Either `global` or `device/<profile_tag>` to specify global
241 * rules or device rules for the given `profile_tag`.
242 *
243 * \param kind
244 * The kind of rule
245 *
246 * \param ruleId
247 * The identifier for the rule.
248 */
249 explicit GetPushRuleActionsJob(const QString& scope, const QString& kind,
250 const QString& ruleId);
251
252 /*! \brief Construct a URL without creating a full-fledged job object
253 *
254 * This function can be used when a URL for GetPushRuleActionsJob
255 * is necessary but the job itself isn't.
256 */
257 static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope,
258 const QString& kind, const QString& ruleId);
259
260 // Result properties
261
262 /// The action(s) to perform for this rule.
263 QVector<QVariant> actions() const
264 {
265 return loadFromJson<QVector<QVariant>>(keyName: "actions"_ls);
266 }
267};
268
269/*! \brief Set the actions for a push rule.
270 *
271 * This endpoint allows clients to change the actions of a push rule.
272 * This can be used to change the actions of builtin rules.
273 */
274class QUOTIENT_API SetPushRuleActionsJob : public BaseJob {
275public:
276 /*! \brief Set the actions for a push rule.
277 *
278 * \param scope
279 * `global` to specify global rules.
280 *
281 * \param kind
282 * The kind of rule
283 *
284 * \param ruleId
285 * The identifier for the rule.
286 *
287 * \param actions
288 * The action(s) to perform for this rule.
289 */
290 explicit SetPushRuleActionsJob(const QString& scope, const QString& kind,
291 const QString& ruleId,
292 const QVector<QVariant>& actions);
293};
294
295} // namespace Quotient
296