diff options
Diffstat (limited to 'lib/csapi/pushrules.cpp')
-rw-r--r-- | lib/csapi/pushrules.cpp | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index d7e416dc..22976641 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -24,8 +24,10 @@ QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) basePath % "/pushrules"); } +static const auto GetPushRulesJobName = QStringLiteral("GetPushRulesJob"); + GetPushRulesJob::GetPushRulesJob() - : BaseJob(HttpVerb::Get, "GetPushRulesJob", + : BaseJob(HttpVerb::Get, GetPushRulesJobName, basePath % "/pushrules") , d(new Private) { @@ -41,10 +43,10 @@ const PushRuleset& GetPushRulesJob::global() const BaseJob::Status GetPushRulesJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("global")) + if (!json.contains("global"_ls)) return { JsonParseError, "The key 'global' not found in the response" }; - d->global = fromJson<PushRuleset>(json.value("global")); + d->global = fromJson<PushRuleset>(json.value("global"_ls)); return Success; } @@ -60,8 +62,10 @@ QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QS basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId); } +static const auto GetPushRuleJobName = QStringLiteral("GetPushRuleJob"); + GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, "GetPushRuleJob", + : BaseJob(HttpVerb::Get, GetPushRuleJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) , d(new Private) { @@ -77,10 +81,10 @@ const PushRule& GetPushRuleJob::data() const BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("data")) + if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson<PushRule>(json.value("data")); + d->data = fromJson<PushRule>(json.value("data"_ls)); return Success; } @@ -90,8 +94,10 @@ QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId); } +static const auto DeletePushRuleJobName = QStringLiteral("DeletePushRuleJob"); + DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Delete, "DeletePushRuleJob", + : BaseJob(HttpVerb::Delete, DeletePushRuleJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) { } @@ -99,20 +105,22 @@ DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, BaseJob::Query queryToSetPushRule(const QString& before, const QString& after) { BaseJob::Query _q; - addParam<IfNotEmpty>(_q, "before", before); - addParam<IfNotEmpty>(_q, "after", after); + addParam<IfNotEmpty>(_q, QStringLiteral("before"), before); + addParam<IfNotEmpty>(_q, QStringLiteral("after"), after); return _q; } +static const auto SetPushRuleJobName = QStringLiteral("SetPushRuleJob"); + SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions, const QString& before, const QString& after, const QVector<PushCondition>& conditions, const QString& pattern) - : BaseJob(HttpVerb::Put, "SetPushRuleJob", + : BaseJob(HttpVerb::Put, SetPushRuleJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId, queryToSetPushRule(before, after)) { QJsonObject _data; - addParam<>(_data, "actions", actions); - addParam<IfNotEmpty>(_data, "conditions", conditions); - addParam<IfNotEmpty>(_data, "pattern", pattern); + addParam<>(_data, QStringLiteral("actions"), actions); + addParam<IfNotEmpty>(_data, QStringLiteral("conditions"), conditions); + addParam<IfNotEmpty>(_data, QStringLiteral("pattern"), pattern); setRequestData(_data); } @@ -128,8 +136,10 @@ QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, co basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled"); } +static const auto IsPushRuleEnabledJobName = QStringLiteral("IsPushRuleEnabledJob"); + IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, "IsPushRuleEnabledJob", + : BaseJob(HttpVerb::Get, IsPushRuleEnabledJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") , d(new Private) { @@ -145,19 +155,21 @@ bool IsPushRuleEnabledJob::enabled() const BaseJob::Status IsPushRuleEnabledJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("enabled")) + if (!json.contains("enabled"_ls)) return { JsonParseError, "The key 'enabled' not found in the response" }; - d->enabled = fromJson<bool>(json.value("enabled")); + d->enabled = fromJson<bool>(json.value("enabled"_ls)); return Success; } +static const auto SetPushRuleEnabledJobName = QStringLiteral("SetPushRuleEnabledJob"); + SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) - : BaseJob(HttpVerb::Put, "SetPushRuleEnabledJob", + : BaseJob(HttpVerb::Put, SetPushRuleEnabledJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") { QJsonObject _data; - addParam<>(_data, "enabled", enabled); + addParam<>(_data, QStringLiteral("enabled"), enabled); setRequestData(_data); } @@ -173,8 +185,10 @@ QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, c basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions"); } +static const auto GetPushRuleActionsJobName = QStringLiteral("GetPushRuleActionsJob"); + GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, "GetPushRuleActionsJob", + : BaseJob(HttpVerb::Get, GetPushRuleActionsJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") , d(new Private) { @@ -190,19 +204,21 @@ const QStringList& GetPushRuleActionsJob::actions() const BaseJob::Status GetPushRuleActionsJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("actions")) + if (!json.contains("actions"_ls)) return { JsonParseError, "The key 'actions' not found in the response" }; - d->actions = fromJson<QStringList>(json.value("actions")); + d->actions = fromJson<QStringList>(json.value("actions"_ls)); return Success; } +static const auto SetPushRuleActionsJobName = QStringLiteral("SetPushRuleActionsJob"); + SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions) - : BaseJob(HttpVerb::Put, "SetPushRuleActionsJob", + : BaseJob(HttpVerb::Put, SetPushRuleActionsJobName, basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") { QJsonObject _data; - addParam<>(_data, "actions", actions); + addParam<>(_data, QStringLiteral("actions"), actions); setRequestData(_data); } |