diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-30 03:36:29 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-30 03:36:29 +0900 |
commit | bcdede472add732c49c95564034c8cfa1c38c725 (patch) | |
tree | f8a67ed14c6439633ec4ddc7f2bb16e235ce97fd | |
parent | 357625eb55e2f4569bb487ffe14a9236188e25f3 (diff) | |
download | libquotient-bcdede472add732c49c95564034c8cfa1c38c725.tar.gz libquotient-bcdede472add732c49c95564034c8cfa1c38c725.zip |
Generated jobs: Apply naming convention to parameters
It's now camelCase everywhere, even if The Spec uses snake_case (it is
not consistent in that respect).
-rw-r--r-- | connection.cpp | 4 | ||||
-rw-r--r-- | jobs/generated/banning.cpp | 8 | ||||
-rw-r--r-- | jobs/generated/banning.h | 4 | ||||
-rw-r--r-- | jobs/generated/inviting.cpp | 4 | ||||
-rw-r--r-- | jobs/generated/inviting.h | 2 | ||||
-rw-r--r-- | jobs/generated/kicking.cpp | 4 | ||||
-rw-r--r-- | jobs/generated/kicking.h | 2 | ||||
-rw-r--r-- | jobs/generated/login.cpp | 42 | ||||
-rw-r--r-- | jobs/generated/login.h | 10 | ||||
-rw-r--r-- | jobs/generated/profile.cpp | 22 | ||||
-rw-r--r-- | jobs/generated/profile.h | 6 | ||||
-rw-r--r-- | jobs/{{base}}.cpp.mustache | 6 | ||||
-rw-r--r-- | jobs/{{base}}.h.mustache | 2 |
13 files changed, 58 insertions, 58 deletions
diff --git a/connection.cpp b/connection.cpp index d2641353..8630f976 100644 --- a/connection.cpp +++ b/connection.cpp @@ -165,8 +165,8 @@ void Connection::doConnectToServer(const QString& user, const QString& password, deviceId, initialDeviceName); connect(loginJob, &BaseJob::success, this, [=] { - d->connectWithToken(loginJob->user_id(), loginJob->access_token(), - loginJob->device_id()); + d->connectWithToken(loginJob->userId(), loginJob->accessToken(), + loginJob->deviceId()); }); connect(loginJob, &BaseJob::failure, this, [=] { diff --git a/jobs/generated/banning.cpp b/jobs/generated/banning.cpp index ebb4c96c..67b0e8a1 100644 --- a/jobs/generated/banning.cpp +++ b/jobs/generated/banning.cpp @@ -12,27 +12,27 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -BanJob::BanJob(QString roomId, QString user_id, QString reason) +BanJob::BanJob(QString roomId, QString userId, QString reason) : BaseJob(HttpVerb::Post, "BanJob", basePath % "/rooms/" % roomId % "/ban", Query { } ) { Data _data; - _data.insert("user_id", toJson(user_id)); + _data.insert("user_id", toJson(userId)); if (!reason.isEmpty()) _data.insert("reason", toJson(reason)); setRequestData(_data); } -UnbanJob::UnbanJob(QString roomId, QString user_id) +UnbanJob::UnbanJob(QString roomId, QString userId) : BaseJob(HttpVerb::Post, "UnbanJob", basePath % "/rooms/" % roomId % "/unban", Query { } ) { Data _data; - _data.insert("user_id", toJson(user_id)); + _data.insert("user_id", toJson(userId)); setRequestData(_data); } diff --git a/jobs/generated/banning.h b/jobs/generated/banning.h index b9d5b8db..e225a6ef 100644 --- a/jobs/generated/banning.h +++ b/jobs/generated/banning.h @@ -18,13 +18,13 @@ namespace QMatrixClient class BanJob : public BaseJob { public: - explicit BanJob(QString roomId, QString user_id, QString reason = {}); + explicit BanJob(QString roomId, QString userId, QString reason = {}); }; class UnbanJob : public BaseJob { public: - explicit UnbanJob(QString roomId, QString user_id); + explicit UnbanJob(QString roomId, QString userId); }; diff --git a/jobs/generated/inviting.cpp b/jobs/generated/inviting.cpp index 73c73076..e72bf734 100644 --- a/jobs/generated/inviting.cpp +++ b/jobs/generated/inviting.cpp @@ -12,14 +12,14 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -InviteUserJob::InviteUserJob(QString roomId, QString user_id) +InviteUserJob::InviteUserJob(QString roomId, QString userId) : BaseJob(HttpVerb::Post, "InviteUserJob", basePath % "/rooms/" % roomId % "/invite", Query { } ) { Data _data; - _data.insert("user_id", toJson(user_id)); + _data.insert("user_id", toJson(userId)); setRequestData(_data); } diff --git a/jobs/generated/inviting.h b/jobs/generated/inviting.h index ac0fd5fa..e4b61beb 100644 --- a/jobs/generated/inviting.h +++ b/jobs/generated/inviting.h @@ -18,7 +18,7 @@ namespace QMatrixClient class InviteUserJob : public BaseJob { public: - explicit InviteUserJob(QString roomId, QString user_id); + explicit InviteUserJob(QString roomId, QString userId); }; diff --git a/jobs/generated/kicking.cpp b/jobs/generated/kicking.cpp index 28d51d05..a0719aa2 100644 --- a/jobs/generated/kicking.cpp +++ b/jobs/generated/kicking.cpp @@ -12,14 +12,14 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -KickJob::KickJob(QString roomId, QString user_id, QString reason) +KickJob::KickJob(QString roomId, QString userId, QString reason) : BaseJob(HttpVerb::Post, "KickJob", basePath % "/rooms/" % roomId % "/kick", Query { } ) { Data _data; - _data.insert("user_id", toJson(user_id)); + _data.insert("user_id", toJson(userId)); if (!reason.isEmpty()) _data.insert("reason", toJson(reason)); setRequestData(_data); diff --git a/jobs/generated/kicking.h b/jobs/generated/kicking.h index 658193d5..e7daada8 100644 --- a/jobs/generated/kicking.h +++ b/jobs/generated/kicking.h @@ -18,7 +18,7 @@ namespace QMatrixClient class KickJob : public BaseJob { public: - explicit KickJob(QString roomId, QString user_id, QString reason = {}); + explicit KickJob(QString roomId, QString userId, QString reason = {}); }; diff --git a/jobs/generated/login.cpp b/jobs/generated/login.cpp index 0c57c684..7bd905ee 100644 --- a/jobs/generated/login.cpp +++ b/jobs/generated/login.cpp @@ -15,14 +15,14 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); class LoginJob::Private { public: - QString user_id; - QString access_token; - QString home_server; - QString device_id; + QString userId; + QString accessToken; + QString homeServer; + QString deviceId; }; -LoginJob::LoginJob(QString type, QString user, QString medium, QString address, QString password, QString token, QString device_id, QString initial_device_display_name) +LoginJob::LoginJob(QString type, QString user, QString medium, QString address, QString password, QString token, QString deviceId, QString initialDeviceDisplayName) : BaseJob(HttpVerb::Post, "LoginJob", basePath % "/login", Query { }, Data { }, false @@ -40,10 +40,10 @@ LoginJob::LoginJob(QString type, QString user, QString medium, QString address, _data.insert("password", toJson(password)); if (!token.isEmpty()) _data.insert("token", toJson(token)); - if (!device_id.isEmpty()) - _data.insert("device_id", toJson(device_id)); - if (!initial_device_display_name.isEmpty()) - _data.insert("initial_device_display_name", toJson(initial_device_display_name)); + if (!deviceId.isEmpty()) + _data.insert("device_id", toJson(deviceId)); + if (!initialDeviceDisplayName.isEmpty()) + _data.insert("initial_device_display_name", toJson(initialDeviceDisplayName)); setRequestData(_data); } @@ -52,37 +52,37 @@ LoginJob::~LoginJob() delete d; } -const QString& LoginJob::user_id() const +const QString& LoginJob::userId() const { - return d->user_id; + return d->userId; } -const QString& LoginJob::access_token() const +const QString& LoginJob::accessToken() const { - return d->access_token; + return d->accessToken; } -const QString& LoginJob::home_server() const +const QString& LoginJob::homeServer() const { - return d->home_server; + return d->homeServer; } -const QString& LoginJob::device_id() const +const QString& LoginJob::deviceId() const { - return d->device_id; + return d->deviceId; } BaseJob::Status LoginJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->user_id = fromJson<QString>(json.value("user_id")); + d->userId = fromJson<QString>(json.value("user_id")); - d->access_token = fromJson<QString>(json.value("access_token")); + d->accessToken = fromJson<QString>(json.value("access_token")); - d->home_server = fromJson<QString>(json.value("home_server")); + d->homeServer = fromJson<QString>(json.value("home_server")); - d->device_id = fromJson<QString>(json.value("device_id")); + d->deviceId = fromJson<QString>(json.value("device_id")); return Success; } diff --git a/jobs/generated/login.h b/jobs/generated/login.h index dc89206d..8fcca09a 100644 --- a/jobs/generated/login.h +++ b/jobs/generated/login.h @@ -18,14 +18,14 @@ namespace QMatrixClient class LoginJob : public BaseJob { public: - explicit LoginJob(QString type, QString user = {}, QString medium = {}, QString address = {}, QString password = {}, QString token = {}, QString device_id = {}, QString initial_device_display_name = {}); + explicit LoginJob(QString type, QString user = {}, QString medium = {}, QString address = {}, QString password = {}, QString token = {}, QString deviceId = {}, QString initialDeviceDisplayName = {}); ~LoginJob() override; - const QString& user_id() const; - const QString& access_token() const; - const QString& home_server() const; - const QString& device_id() const; + const QString& userId() const; + const QString& accessToken() const; + const QString& homeServer() const; + const QString& deviceId() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/jobs/generated/profile.cpp b/jobs/generated/profile.cpp index f24db15a..f682ad31 100644 --- a/jobs/generated/profile.cpp +++ b/jobs/generated/profile.cpp @@ -57,22 +57,22 @@ BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) return Success; } -SetAvatarUrlJob::SetAvatarUrlJob(QString userId, QString avatar_url) +SetAvatarUrlJob::SetAvatarUrlJob(QString userId, QString avatarUrl) : BaseJob(HttpVerb::Put, "SetAvatarUrlJob", basePath % "/profile/" % userId % "/avatar_url", Query { } ) { Data _data; - if (!avatar_url.isEmpty()) - _data.insert("avatar_url", toJson(avatar_url)); + if (!avatarUrl.isEmpty()) + _data.insert("avatar_url", toJson(avatarUrl)); setRequestData(_data); } class GetAvatarUrlJob::Private { public: - QString avatar_url; + QString avatarUrl; }; @@ -88,16 +88,16 @@ GetAvatarUrlJob::~GetAvatarUrlJob() delete d; } -const QString& GetAvatarUrlJob::avatar_url() const +const QString& GetAvatarUrlJob::avatarUrl() const { - return d->avatar_url; + return d->avatarUrl; } BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->avatar_url = fromJson<QString>(json.value("avatar_url")); + d->avatarUrl = fromJson<QString>(json.value("avatar_url")); return Success; } @@ -105,7 +105,7 @@ BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) class GetUserProfileJob::Private { public: - QString avatar_url; + QString avatarUrl; QString displayname; }; @@ -122,9 +122,9 @@ GetUserProfileJob::~GetUserProfileJob() delete d; } -const QString& GetUserProfileJob::avatar_url() const +const QString& GetUserProfileJob::avatarUrl() const { - return d->avatar_url; + return d->avatarUrl; } const QString& GetUserProfileJob::displayname() const @@ -136,7 +136,7 @@ BaseJob::Status GetUserProfileJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->avatar_url = fromJson<QString>(json.value("avatar_url")); + d->avatarUrl = fromJson<QString>(json.value("avatar_url")); d->displayname = fromJson<QString>(json.value("displayname")); diff --git a/jobs/generated/profile.h b/jobs/generated/profile.h index 8e2b195b..cd460ac3 100644 --- a/jobs/generated/profile.h +++ b/jobs/generated/profile.h @@ -40,7 +40,7 @@ namespace QMatrixClient class SetAvatarUrlJob : public BaseJob { public: - explicit SetAvatarUrlJob(QString userId, QString avatar_url = {}); + explicit SetAvatarUrlJob(QString userId, QString avatarUrl = {}); }; class GetAvatarUrlJob : public BaseJob @@ -50,7 +50,7 @@ namespace QMatrixClient ~GetAvatarUrlJob() override; - const QString& avatar_url() const; + const QString& avatarUrl() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -66,7 +66,7 @@ namespace QMatrixClient ~GetUserProfileJob() override; - const QString& avatar_url() const; + const QString& avatarUrl() const; const QString& displayname() const; protected: diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache index f3a6dc59..31b867fa 100644 --- a/jobs/{{base}}.cpp.mustache +++ b/jobs/{{base}}.cpp.mustache @@ -2,7 +2,7 @@ #include "{{filenameBase}}.h" -{{^models}}#include "jobs/converters.h"{{/models}} +{{^models}}#include "converters.h"{{/models}} {{#operations}}#include <QtCore/QStringBuilder>{{/operations}} using namespace QMatrixClient; @@ -35,7 +35,7 @@ class {{camelCaseOperationId}}Job::Private {{/ properties?}}{{/normalResponse?}}{{/responses}} {{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{#avoidCopy?}}const {{dataType}}&{{/avoidCopy?}}{{^avoidCopy?}}{{dataType}}{{/avoidCopy?}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job", - basePath{{#pathParts}} % {{part}}{{/pathParts}}, + basePath{{#pathParts}} % {{.}}{{/pathParts}}, Query {{^queryParams}}{ }{{/queryParams}}{{#queryParams?}}{ {{#queryParams}}{ "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, {{/hasMore}}{{/queryParams}} @@ -69,7 +69,7 @@ BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data {{# properties}}{{#required?}}if (!json.contains("{{paramName}}")) return { JsonParseError, "The key '{{paramName}}' not found in the response" };{{/required?}} - d->{{paramName}} = fromJson<{{dataType}}>(json.value("{{paramName}}")); + d->{{paramName}} = fromJson<{{dataType}}>(json.value("{{baseName}}")); {{/ properties}} return Success; }{{/ returnFile?}} diff --git a/jobs/{{base}}.h.mustache b/jobs/{{base}}.h.mustache index 65c79e24..a751df9d 100644 --- a/jobs/{{base}}.h.mustache +++ b/jobs/{{base}}.h.mustache @@ -6,7 +6,7 @@ {{/operations}} {{#imports}}#include {{.}} {{/imports}} -{{#models}}#include "jobs/converters.h" +{{#models}}#include "converters.h" {{/models}} namespace QMatrixClient { |