1 /****************************************************************************** 2 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN 3 */ 4 5 #include "whoami.h" 6 7 #include "converters.h" 8 9 #include <QtCore/QStringBuilder> 10 11 using namespace Quotient; 12 13 static const auto basePath = QStringLiteral("/_matrix/client/r0"); 14 15 class GetTokenOwnerJob::Private 16 { 17 public: 18 QString userId; 19 }; 20 makeRequestUrl(QUrl baseUrl)21QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) 22 { 23 return BaseJob::makeRequestUrl(std::move(baseUrl), 24 basePath % "/account/whoami"); 25 } 26 27 static const auto GetTokenOwnerJobName = QStringLiteral("GetTokenOwnerJob"); 28 GetTokenOwnerJob()29GetTokenOwnerJob::GetTokenOwnerJob() 30 : BaseJob(HttpVerb::Get, GetTokenOwnerJobName, basePath % "/account/whoami") 31 , d(new Private) 32 {} 33 34 GetTokenOwnerJob::~GetTokenOwnerJob() = default; 35 userId() const36const QString& GetTokenOwnerJob::userId() const { return d->userId; } 37 parseJson(const QJsonDocument & data)38BaseJob::Status GetTokenOwnerJob::parseJson(const QJsonDocument& data) 39 { 40 auto json = data.object(); 41 if (!json.contains("user_id"_ls)) 42 return { IncorrectResponse, 43 "The key 'user_id' not found in the response" }; 44 fromJson(json.value("user_id"_ls), d->userId); 45 46 return Success; 47 } 48