Newer
Older
/********************************************************************************************
* *
* Copyright (C) 2017 Armin Felder, Dennis Beier *
* This file is part of RocketChatMobileEngine <https://git.fairkom.net/chat/fairchat>. *
* *
* RocketChatMobileEngine is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* RocketChatMobileEngine is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with RocketChatMobileEngine. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************************/
#ifndef RESTREQUEST_H
#define RESTREQUEST_H
#include <QJsonObject>
#include <functional>
class RestApi;
class QNetworkReply;
typedef std::function<void (QNetworkReply *,QJsonObject pData, RestApi*)> RestRequestCallback;
class RestRequest
{
public:
enum class methods {
GET,
POST
};
RestRequest(const QByteArray&, const QString&, methods, const RestRequestCallback&);
RestRequest(const QByteArray&, const QString& , methods, const RestRequestCallback &pSuccess, const RestRequestCallback &pError);
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
methods getMethod() const;
void setMethod(const methods &pValue);
QString getPath() const;
void setPath(const QString &pValue);
QByteArray getContent() const;
void setContent(const QByteArray &pValue);
RestRequestCallback getSuccess() const;
void setSuccess(const RestRequestCallback &pValue);
RestRequestCallback getError() const;
void setError(const RestRequestCallback &pValue);
QString getMimeType() const;
void setMimeType(const QString &pValue);
bool isRawData();
bool getAbsolutePath() const;
protected:
RestRequest();
QByteArray mContent;
QString mPath;
methods mMethod;
RestRequestCallback mSuccess = nullptr;
RestRequestCallback mError = nullptr;
QString mMimeType = "text/plain";
bool mAbsolutePath = false;
bool mRawData = false;
};
#endif // RESTREQUEST_H