aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/push_rule.cpp
blob: 1ee57945fd4263b035e260c4c9e4e488a78e667f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "push_rule.h"

using namespace QMatrixClient;

QJsonObject QMatrixClient::toJson(const SetTweakAction& pod)
{
    QJsonObject _json = toJson(pod.additionalProperties);
    addParam<>(_json, QStringLiteral("set_tweak"), pod.setTweak);
    return _json;
}

SetTweakAction FromJson<SetTweakAction>::operator()(const QJsonValue& jv)
{
    auto _json = jv.toObject();
    SetTweakAction result;
    result.setTweak =
        fromJson<QString>(_json.take("set_tweak"_ls));
    
    result.additionalProperties = fromJson<QVariantHash>(_json);
    return result;
}

QJsonObject QMatrixClient::toJson(const PushRule& pod)
{
    QJsonObject _json;
    addParam<>(_json, QStringLiteral("actions"), pod.actions);
    addParam<>(_json, QStringLiteral("default"), pod.isDefault);
    addParam<>(_json, QStringLiteral("enabled"), pod.enabled);
    addParam<>(_json, QStringLiteral("rule_id"), pod.ruleId);
    addParam<IfNotEmpty>(_json, QStringLiteral("conditions"), pod.conditions);
    addParam<IfNotEmpty>(_json, QStringLiteral("pattern"), pod.pattern);
    return _json;
}

PushRule FromJson<PushRule>::operator()(const QJsonValue& jv)
{
    const auto& _json = jv.toObject();
    PushRule result;
    result.actions =
        fromJson<QVector<QVariant>>(_json.value("actions"_ls));
    result.isDefault =
        fromJson<bool>(_json.value("default"_ls));
    result.enabled =
        fromJson<bool>(_json.value("enabled"_ls));
    result.ruleId =
        fromJson<QString>(_json.value("rule_id"_ls));
    result.conditions =
        fromJson<QVector<PushCondition>>(_json.value("conditions"_ls));
    result.pattern =
        fromJson<QString>(_json.value("pattern"_ls));
    
    return result;
}