libkazv
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 
10 namespace Kazv::Api {
11 
12 struct PushRule
13 {
14 
16  immer::array<Variant> actions;
17 
19  bool isDefault;
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 }
38 namespace nlohmann
39 {
40 using namespace Kazv;
41 using namespace Kazv::Api;
42 template<>
43 struct 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
Kazv::Api::PushRule
Definition: push_rule.hpp:14
nlohmann::adl_serializer< PushRule >::from_json
static void from_json(const json &jo, PushRule &result)
Definition: push_rule.hpp:62
Kazv::Api::PushRule::conditions
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:34
types.hpp
nlohmann
Definition: location.hpp:26
Kazv
Definition: location.hpp:10
Kazv::Api::PushRule::pattern
std::optional< std::string > pattern
The glob-style pattern to match against.
Definition: push_rule.hpp:38
push_condition.hpp
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api
Definition: location.hpp:10
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
Kazv::Api::PushRule::actions
immer::array< Variant > actions
The actions to perform when this rule is matched.
Definition: push_rule.hpp:20
Kazv::Api::PushRule::ruleId
std::string ruleId
The ID of this rule.
Definition: push_rule.hpp:29
Kazv::Api::PushRule::enabled
bool enabled
Whether the push rule is enabled or not.
Definition: push_rule.hpp:26
nlohmann::adl_serializer< PushRule >::to_json
static void to_json(json &jo, const PushRule &pod)
Definition: push_rule.hpp:44
Kazv::Api::PushRule::isDefault
bool isDefault
Whether this is a default rule, or has been set explicitly.
Definition: push_rule.hpp:23