aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/device_keys.h
blob: 84ecefae96493a1eed7cf9c7bba940c06feb44df (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
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "converters.h"

namespace Quotient {
/// Device identity keys
struct DeviceKeys {
    /// The ID of the user the device belongs to. Must match the user ID used
    /// when logging in.
    QString userId;

    /// The ID of the device these keys belong to. Must match the device ID used
    /// when logging in.
    QString deviceId;

    /// The encryption algorithms supported by this device.
    QStringList algorithms;

    /// Public identity keys. The names of the properties should be in the
    /// format `<algorithm>:<device_id>`. The keys themselves should be
    /// encoded as specified by the key algorithm.
    QHash<QString, QString> keys;

    /// Signatures for the device key object. A map from user ID, to a map from
    /// `<algorithm>:<device_id>` to the signature.
    ///
    /// The signature is calculated using the process described at [Signing
    /// JSON](/appendices/#signing-json).
    QHash<QString, QHash<QString, QString>> signatures;
};

template <>
struct JsonObjectConverter<DeviceKeys> {
    static void dumpTo(QJsonObject& jo, const DeviceKeys& pod)
    {
        addParam<>(jo, QStringLiteral("user_id"), pod.userId);
        addParam<>(jo, QStringLiteral("device_id"), pod.deviceId);
        addParam<>(jo, QStringLiteral("algorithms"), pod.algorithms);
        addParam<>(jo, QStringLiteral("keys"), pod.keys);
        addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
    }
    static void fillFrom(const QJsonObject& jo, DeviceKeys& pod)
    {
        fromJson(jo.value("user_id"_ls), pod.userId);
        fromJson(jo.value("device_id"_ls), pod.deviceId);
        fromJson(jo.value("algorithms"_ls), pod.algorithms);
        fromJson(jo.value("keys"_ls), pod.keys);
        fromJson(jo.value("signatures"_ls), pod.signatures);
    }
};

} // namespace Quotient
s="n">ThirdPartyProtocol> data; }; QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/protocols"); } static const auto GetProtocolsJobName = QStringLiteral("GetProtocolsJob"); GetProtocolsJob::GetProtocolsJob() : BaseJob(HttpVerb::Get, GetProtocolsJobName, basePath % "/thirdparty/protocols") , d(new Private) { } GetProtocolsJob::~GetProtocolsJob() = default; const QHash<QString, ThirdPartyProtocol>& GetProtocolsJob::data() const { return d->data; } BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } class GetProtocolMetadataJob::Private { public: ThirdPartyProtocol data; }; QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/protocol/" % protocol); } static const auto GetProtocolMetadataJobName = QStringLiteral("GetProtocolMetadataJob"); GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) : BaseJob(HttpVerb::Get, GetProtocolMetadataJobName, basePath % "/thirdparty/protocol/" % protocol) , d(new Private) { } GetProtocolMetadataJob::~GetProtocolMetadataJob() = default; const ThirdPartyProtocol& GetProtocolMetadataJob::data() const { return d->data; } BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } class QueryLocationByProtocolJob::Private { public: QVector<ThirdPartyLocation> data; }; BaseJob::Query queryToQueryLocationByProtocol(const QString& searchFields) { BaseJob::Query _q; addParam<IfNotEmpty>(_q, QStringLiteral("searchFields"), searchFields); return _q; } QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/location/" % protocol, queryToQueryLocationByProtocol(searchFields)); } static const auto QueryLocationByProtocolJobName = QStringLiteral("QueryLocationByProtocolJob"); QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields) : BaseJob(HttpVerb::Get, QueryLocationByProtocolJobName, basePath % "/thirdparty/location/" % protocol, queryToQueryLocationByProtocol(searchFields)) , d(new Private) { } QueryLocationByProtocolJob::~QueryLocationByProtocolJob() = default; const QVector<ThirdPartyLocation>& QueryLocationByProtocolJob::data() const { return d->data; } BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } class QueryUserByProtocolJob::Private { public: QVector<ThirdPartyUser> data; }; BaseJob::Query queryToQueryUserByProtocol(const QString& fields) { BaseJob::Query _q; addParam<IfNotEmpty>(_q, QStringLiteral("fields..."), fields); return _q; } QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/user/" % protocol, queryToQueryUserByProtocol(fields)); } static const auto QueryUserByProtocolJobName = QStringLiteral("QueryUserByProtocolJob"); QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) : BaseJob(HttpVerb::Get, QueryUserByProtocolJobName, basePath % "/thirdparty/user/" % protocol, queryToQueryUserByProtocol(fields)) , d(new Private) { } QueryUserByProtocolJob::~QueryUserByProtocolJob() = default; const QVector<ThirdPartyUser>& QueryUserByProtocolJob::data() const { return d->data; } BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } class QueryLocationByAliasJob::Private { public: QVector<ThirdPartyLocation> data; }; BaseJob::Query queryToQueryLocationByAlias(const QString& alias) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("alias"), alias); return _q; } QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/location", queryToQueryLocationByAlias(alias)); } static const auto QueryLocationByAliasJobName = QStringLiteral("QueryLocationByAliasJob"); QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) : BaseJob(HttpVerb::Get, QueryLocationByAliasJobName, basePath % "/thirdparty/location", queryToQueryLocationByAlias(alias)) , d(new Private) { } QueryLocationByAliasJob::~QueryLocationByAliasJob() = default; const QVector<ThirdPartyLocation>& QueryLocationByAliasJob::data() const { return d->data; } BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } class QueryUserByIDJob::Private { public: QVector<ThirdPartyUser> data; }; BaseJob::Query queryToQueryUserByID(const QString& userid) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("userid"), userid); return _q; } QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thirdparty/user", queryToQueryUserByID(userid)); } static const auto QueryUserByIDJobName = QStringLiteral("QueryUserByIDJob"); QueryUserByIDJob::QueryUserByIDJob(const QString& userid) : BaseJob(HttpVerb::Get, QueryUserByIDJobName, basePath % "/thirdparty/user", queryToQueryUserByID(userid)) , d(new Private) { } QueryUserByIDJob::~QueryUserByIDJob() = default; const QVector<ThirdPartyUser>& QueryUserByIDJob::data() const { return d->data; } BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; }