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
9#include <Quotient/converters.h>
10
11namespace Quotient {
12
13struct PushRule {
14 /// The actions to perform when this rule is matched.
15 QVector<QVariant> actions;
16
17 /// Whether this is a default rule, or has been set explicitly.
18 bool isDefault;
19
20 /// Whether the push rule is enabled or not.
21 bool enabled;
22
23 /// The ID of this rule.
24 QString ruleId;
25
26 /// The conditions that must hold true for an event in order for a rule to
27 /// be applied to an event. A rule with no conditions always matches. Only
28 /// applicable to `underride` and `override` rules.
29 QVector<PushCondition> conditions{};
30
31 /// The [glob-style pattern](/appendices#glob-style-matching) to match
32 /// against. Only applicable to `content` rules.
33 QString pattern{};
34};
35
36template <>
37struct JsonObjectConverter<PushRule> {
38 static void dumpTo(QJsonObject& jo, const PushRule& pod)
39 {
40 addParam<>(container&: jo, QStringLiteral("actions"), value: pod.actions);
41 addParam<>(container&: jo, QStringLiteral("default"), value: pod.isDefault);
42 addParam<>(container&: jo, QStringLiteral("enabled"), value: pod.enabled);
43 addParam<>(container&: jo, QStringLiteral("rule_id"), value: pod.ruleId);
44 addParam<IfNotEmpty>(container&: jo, QStringLiteral("conditions"), value: pod.conditions);
45 addParam<IfNotEmpty>(container&: jo, QStringLiteral("pattern"), value: pod.pattern);
46 }
47 static void fillFrom(const QJsonObject& jo, PushRule& pod)
48 {
49 fillFromJson(jv: jo.value(key: "actions"_ls), pod&: pod.actions);
50 fillFromJson(jv: jo.value(key: "default"_ls), pod&: pod.isDefault);
51 fillFromJson(jv: jo.value(key: "enabled"_ls), pod&: pod.enabled);
52 fillFromJson(jv: jo.value(key: "rule_id"_ls), pod&: pod.ruleId);
53 fillFromJson(jv: jo.value(key: "conditions"_ls), pod&: pod.conditions);
54 fillFromJson(jv: jo.value(key: "pattern"_ls), pod&: pod.pattern);
55 }
56};
57
58} // namespace Quotient
59