libkazv
Loading...
Searching...
No Matches
push_rule.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3 */
4
5#pragma once
6
7#include "types.hpp"
9
10namespace Kazv::Api {
11
13{
14
16 immer::array<Variant> actions;
17
20
22 bool enabled;
23
25 std::string ruleId;
26
30 immer::array<PushCondition> conditions;
31
34 std::optional<std::string> pattern;
35};
36
37}
38namespace nlohmann
39{
40using namespace Kazv;
41using namespace Kazv::Api;
42template<>
43struct adl_serializer<PushRule> {
44 static void to_json(json& jo, const PushRule &pod)
45 {
46 if (! jo.is_object()) { jo = json::object(); }
47
48
49 jo["actions"s] = pod.actions;
50
51 jo["default"s] = pod.isDefault;
52
53 jo["enabled"s] = pod.enabled;
54
55 jo["rule_id"s] = pod.ruleId;
56
57
58 addToJsonIfNeeded(jo, "conditions"s, pod.conditions);
59
60 addToJsonIfNeeded(jo, "pattern"s, pod.pattern);
61 }
62 static void from_json(const json &jo, PushRule& result)
63 {
64
65 if (jo.contains("actions"s)) {
66 result.actions = jo.at("actions"s);
67 }
68 if (jo.contains("default"s)) {
69 result.isDefault = jo.at("default"s);
70 }
71 if (jo.contains("enabled"s)) {
72 result.enabled = jo.at("enabled"s);
73 }
74 if (jo.contains("rule_id"s)) {
75 result.ruleId = jo.at("rule_id"s);
76 }
77 if (jo.contains("conditions"s)) {
78 result.conditions = jo.at("conditions"s);
79 }
80 if (jo.contains("pattern"s)) {
81 result.pattern = jo.at("pattern"s);
82 }
83
84 }
85};
86 }
87
88 namespace Kazv::Api
89 {
90} // namespace Kazv::Api
Definition location.hpp:10
Definition location.hpp:10
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition types.hpp:80
nlohmann::json json
Definition jsonwrap.hpp:20
Definition location.hpp:27
Definition push_rule.hpp:13
std::optional< std::string > pattern
The glob-style pattern to match against.
Definition push_rule.hpp:34
immer::array< PushCondition > conditions
The conditions that must hold true for an event in order for a rule to be applied to an event.
Definition push_rule.hpp:30
immer::array< Variant > actions
The actions to perform when this rule is matched.
Definition push_rule.hpp:16
bool enabled
Whether the push rule is enabled or not.
Definition push_rule.hpp:22
bool isDefault
Whether this is a default rule, or has been set explicitly.
Definition push_rule.hpp:19
std::string ruleId
The ID of this rule.
Definition push_rule.hpp:25
static void from_json(const json &jo, PushRule &result)
Definition push_rule.hpp:62
static void to_json(json &jo, const PushRule &pod)
Definition push_rule.hpp:44