Added CreateAbsenceReply
This commit is contained in:
59
zeiterfassungcorelib/replies/createabsencereply.cpp
Normal file
59
zeiterfassungcorelib/replies/createabsencereply.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "createabsencereply.h"
|
||||
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
CreateAbsenceReply::CreateAbsenceReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
||||
ZeiterfassungReply(zeiterfassung),
|
||||
m_reply(std::move(reply))
|
||||
{
|
||||
connect(m_reply.get(), &QNetworkReply::finished, this, &CreateAbsenceReply::requestFinished);
|
||||
}
|
||||
|
||||
void CreateAbsenceReply::requestFinished()
|
||||
{
|
||||
if(m_reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
setSuccess(false);
|
||||
setMessage(tr("Request error occured: %0").arg(m_reply->errorString()));
|
||||
goto end;
|
||||
}
|
||||
|
||||
{
|
||||
QJsonParseError error;
|
||||
QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll(), &error);
|
||||
if(error.error != QJsonParseError::NoError)
|
||||
{
|
||||
setSuccess(false);
|
||||
setMessage(tr("Parsing JSON failed: %0").arg(error.errorString()));
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(!document.isObject())
|
||||
{
|
||||
setSuccess(false);
|
||||
setMessage(tr("JSON document is not an array!"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
auto obj = document.object();
|
||||
|
||||
if(!obj.contains(QStringLiteral("compositeId")))
|
||||
{
|
||||
setSuccess(false);
|
||||
setMessage(tr("JSON does not contain compositeId!"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
m_compositeId = obj.value(QStringLiteral("compositeId")).toString();
|
||||
|
||||
setSuccess(true);
|
||||
}
|
||||
|
||||
end:
|
||||
m_reply = Q_NULLPTR;
|
||||
|
||||
Q_EMIT finished();
|
||||
}
|
26
zeiterfassungcorelib/replies/createabsencereply.h
Normal file
26
zeiterfassungcorelib/replies/createabsencereply.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "zeiterfassungcorelib_global.h"
|
||||
#include "zeiterfassungreply.h"
|
||||
|
||||
class ZEITERFASSUNGCORELIBSHARED_EXPORT CreateAbsenceReply : public ZeiterfassungReply
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CreateAbsenceReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung);
|
||||
|
||||
const QString &compositeId() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void requestFinished();
|
||||
|
||||
private:
|
||||
std::unique_ptr<QNetworkReply> m_reply;
|
||||
|
||||
QString m_compositeId;
|
||||
};
|
@@ -17,7 +17,6 @@ void DeleteBookingReply::requestFinished()
|
||||
}
|
||||
|
||||
//should be empty, so nothing to check...
|
||||
|
||||
setSuccess(true);
|
||||
|
||||
end:
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include "gettimeassignmentsreply.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
#include "loginpagereply.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
LoginPageReply::LoginPageReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
||||
ZeiterfassungReply(zeiterfassung),
|
||||
m_reply(std::move(reply))
|
||||
|
@@ -1,7 +1,5 @@
|
||||
#include "loginreply.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
LoginReply::LoginReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
||||
ZeiterfassungReply(zeiterfassung),
|
||||
m_reply(std::move(reply))
|
||||
|
@@ -66,6 +66,7 @@ public:
|
||||
std::unique_ptr<GetProjectsReply> doGetProjects(int userId, const QDate &date);
|
||||
std::unique_ptr<GetReportReply> doGetReport(int userId, const QDate &date);
|
||||
std::unique_ptr<GetPresenceStatusReply> doGetPresenceStatus();
|
||||
|
||||
std::unique_ptr<GetAbsencesReply> doGetAbsences(int userId, const QDate &start, const QDate &end);
|
||||
std::unique_ptr<GetDayinfoReply> doGetDayinfo(int userId, const QDate &start, const QDate &end);
|
||||
|
||||
|
@@ -11,6 +11,7 @@ DEFINES += ZEITERFASSUNGCORELIB_LIBRARY
|
||||
SOURCES += timeutils.cpp \
|
||||
zeiterfassungapi.cpp \
|
||||
zeiterfassungsettings.cpp \
|
||||
replies/createabsencereply.cpp \
|
||||
replies/createbookingreply.cpp \
|
||||
replies/createtimeassignmentreply.cpp \
|
||||
replies/deletebookingreply.cpp \
|
||||
@@ -34,6 +35,7 @@ HEADERS += cpp14polyfills.h \
|
||||
zeiterfassungapi.h \
|
||||
zeiterfassungcorelib_global.h \
|
||||
zeiterfassungsettings.h \
|
||||
replies/createabsencereply.h \
|
||||
replies/createbookingreply.h \
|
||||
replies/createtimeassignmentreply.h \
|
||||
replies/deletebookingreply.h \
|
||||
|
Reference in New Issue
Block a user