aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/presence.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-09 08:52:25 +0200
committerGitHub <noreply@github.com>2020-06-09 08:52:25 +0200
commit370d9b3e46332d38df8798cda208c534c58be808 (patch)
treef3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/presence.h
parente1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff)
parent10d9ac4673e374a9ac17ff492591136520337c4c (diff)
downloadlibquotient-370d9b3e46332d38df8798cda208c534c58be808.tar.gz
libquotient-370d9b3e46332d38df8798cda208c534c58be808.zip
Merge pull request #405 from quotient-im/kitsune-basejob-store-json-response
Store JSON response in BaseJob + tweaks to the generated code
Diffstat (limited to 'lib/csapi/presence.h')
-rw-r--r--lib/csapi/presence.h30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h
index 21e57603..b34028e7 100644
--- a/lib/csapi/presence.h
+++ b/lib/csapi/presence.h
@@ -4,14 +4,10 @@
#pragma once
-#include "converters.h"
-
#include "jobs/basejob.h"
namespace Quotient {
-// Operations
-
/*! \brief Update this user's presence state.
*
* This API sets the given user's presence state. When setting the status,
@@ -23,10 +19,13 @@ class SetPresenceJob : public BaseJob {
public:
/*! \brief Update this user's presence state.
*
+ *
* \param userId
* The user whose presence state to update.
+ *
* \param presence
* The new presence state.
+ *
* \param statusMsg
* The status message to attach to this state.
*/
@@ -42,6 +41,7 @@ class GetPresenceJob : public BaseJob {
public:
/*! \brief Get this user's presence state.
*
+ *
* \param userId
* The user whose presence state to get.
*/
@@ -53,29 +53,27 @@ public:
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);
- ~GetPresenceJob() override;
// Result properties
/// This user's presence.
- const QString& presence() const;
+ QString presence() const { return loadFromJson<QString>("presence"_ls); }
/// The length of time in milliseconds since an action was performed
/// by this user.
- Omittable<int> lastActiveAgo() const;
+ Omittable<int> lastActiveAgo() const
+ {
+ return loadFromJson<Omittable<int>>("last_active_ago"_ls);
+ }
/// The state message for this user if one was set.
- const QString& statusMsg() const;
+ QString statusMsg() const { return loadFromJson<QString>("status_msg"_ls); }
/// Whether the user is currently active
- Omittable<bool> currentlyActive() const;
-
-protected:
- Status parseJson(const QJsonDocument& data) override;
-
-private:
- class Private;
- QScopedPointer<Private> d;
+ Omittable<bool> currentlyActive() const
+ {
+ return loadFromJson<Omittable<bool>>("currently_active"_ls);
+ }
};
} // namespace Quotient