aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/device_management.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
commit6a9de91752dfe75e185bf90ab856367b2c804582 (patch)
tree2a12ecc84bf0055e317ef2e4aeec3439d92b2035 /lib/csapi/device_management.cpp
parentd5397fe5ae2ca34d5cfb11394dac17728a2b50ce (diff)
parent5d1dd53890611376873f6f959e206d5a56cfff70 (diff)
downloadlibquotient-6a9de91752dfe75e185bf90ab856367b2c804582.tar.gz
libquotient-6a9de91752dfe75e185bf90ab856367b2c804582.zip
Merge branch 'kitsune-events-rewritten'
Diffstat (limited to 'lib/csapi/device_management.cpp')
-rw-r--r--lib/csapi/device_management.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp
index a4b2daae..bbc7e674 100644
--- a/lib/csapi/device_management.cpp
+++ b/lib/csapi/device_management.cpp
@@ -24,8 +24,10 @@ QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl)
basePath % "/devices");
}
+static const auto GetDevicesJobName = QStringLiteral("GetDevicesJob");
+
GetDevicesJob::GetDevicesJob()
- : BaseJob(HttpVerb::Get, "GetDevicesJob",
+ : BaseJob(HttpVerb::Get, GetDevicesJobName,
basePath % "/devices")
, d(new Private)
{
@@ -41,7 +43,7 @@ const QVector<Device>& GetDevicesJob::devices() const
BaseJob::Status GetDevicesJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
- d->devices = fromJson<QVector<Device>>(json.value("devices"));
+ d->devices = fromJson<QVector<Device>>(json.value("devices"_ls));
return Success;
}
@@ -57,8 +59,10 @@ QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId)
basePath % "/devices/" % deviceId);
}
+static const auto GetDeviceJobName = QStringLiteral("GetDeviceJob");
+
GetDeviceJob::GetDeviceJob(const QString& deviceId)
- : BaseJob(HttpVerb::Get, "GetDeviceJob",
+ : BaseJob(HttpVerb::Get, GetDeviceJobName,
basePath % "/devices/" % deviceId)
, d(new Private)
{
@@ -74,38 +78,44 @@ const Device& GetDeviceJob::data() const
BaseJob::Status GetDeviceJob::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<Device>(json.value("data"));
+ d->data = fromJson<Device>(json.value("data"_ls));
return Success;
}
+static const auto UpdateDeviceJobName = QStringLiteral("UpdateDeviceJob");
+
UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName)
- : BaseJob(HttpVerb::Put, "UpdateDeviceJob",
+ : BaseJob(HttpVerb::Put, UpdateDeviceJobName,
basePath % "/devices/" % deviceId)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, "display_name", displayName);
+ addParam<IfNotEmpty>(_data, QStringLiteral("display_name"), displayName);
setRequestData(_data);
}
+static const auto DeleteDeviceJobName = QStringLiteral("DeleteDeviceJob");
+
DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const QJsonObject& auth)
- : BaseJob(HttpVerb::Delete, "DeleteDeviceJob",
+ : BaseJob(HttpVerb::Delete, DeleteDeviceJobName,
basePath % "/devices/" % deviceId)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, "auth", auth);
+ addParam<IfNotEmpty>(_data, QStringLiteral("auth"), auth);
setRequestData(_data);
}
+static const auto DeleteDevicesJobName = QStringLiteral("DeleteDevicesJob");
+
DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const QJsonObject& auth)
- : BaseJob(HttpVerb::Post, "DeleteDevicesJob",
+ : BaseJob(HttpVerb::Post, DeleteDevicesJobName,
basePath % "/delete_devices")
{
QJsonObject _data;
- addParam<>(_data, "devices", devices);
- addParam<IfNotEmpty>(_data, "auth", auth);
+ addParam<>(_data, QStringLiteral("devices"), devices);
+ addParam<IfNotEmpty>(_data, QStringLiteral("auth"), auth);
setRequestData(_data);
}