aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/generated/administrative_contact.cpp
blob: fc75fd85357ae898e5ea6924f7627b2fd907ccb1 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "administrative_contact.h"

#include <QtCore/QStringBuilder>

using namespace QMatrixClient;

static const auto basePath = QStringLiteral("/_matrix/client/r0");

namespace QMatrixClient
{
    QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod)
    {
        QJsonObject o;
        o.insert("medium", toJson(pod.medium));
        o.insert("address", toJson(pod.address));
        
        return o;
    }

    template <> struct FromJson<GetAccount3PIDsJob::ThirdPartyIdentifier>
    {
        GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv)
        {
            const auto& o = jv.toObject();
            GetAccount3PIDsJob::ThirdPartyIdentifier result;
            result.medium =
                fromJson<QString>(o.value("medium"));
            result.address =
                fromJson<QString>(o.value("address"));
            
            return result;
        }
    };
} // namespace QMatrixClient

class GetAccount3PIDsJob::Private
{
    public:
        QVector<ThirdPartyIdentifier> threepids;
};

QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl)
{
    return BaseJob::makeRequestUrl(baseUrl,
            basePath % "/account/3pid");
}

GetAccount3PIDsJob::GetAccount3PIDsJob()
    : BaseJob(HttpVerb::Get, "GetAccount3PIDsJob",
        basePath % "/account/3pid")
    , d(new Private)
{
}

GetAccount3PIDsJob::~GetAccount3PIDsJob() = default;

const QVector<GetAccount3PIDsJob::ThirdPartyIdentifier>& GetAccount3PIDsJob::threepids() const
{
    return d->threepids;
}

BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    d->threepids = fromJson<QVector<ThirdPartyIdentifier>>(json.value("threepids"));
    return Success;
}

namespace QMatrixClient
{
    QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod)
    {
        QJsonObject o;
        o.insert("client_secret", toJson(pod.clientSecret));
        o.insert("id_server", toJson(pod.idServer));
        o.insert("sid", toJson(pod.sid));
        
        return o;
    }

    template <> struct FromJson<Post3PIDsJob::ThreePidCredentials>
    {
        Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv)
        {
            const auto& o = jv.toObject();
            Post3PIDsJob::ThreePidCredentials result;
            result.clientSecret =
                fromJson<QString>(o.value("client_secret"));
            result.idServer =
                fromJson<QString>(o.value("id_server"));
            result.sid =
                fromJson<QString>(o.value("sid"));
            
            return result;
        }
    };
} // namespace QMatrixClient

Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind)
    : BaseJob(HttpVerb::Post, "Post3PIDsJob",
        basePath % "/account/3pid")
{
    QJsonObject _data;
    _data.insert("three_pid_creds", toJson(threePidCreds));
    _data.insert("bind", toJson(bind));
    setRequestData(_data);
}

QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl)
{
    return BaseJob::makeRequestUrl(baseUrl,
            basePath % "/account/3pid/email/requestToken");
}

RequestTokenTo3PIDJob::RequestTokenTo3PIDJob()
    : BaseJob(HttpVerb::Post, "RequestTokenTo3PIDJob",
        basePath % "/account/3pid/email/requestToken", false)
{
}