qTbot 0.2.123.6f57966
qTbot is base back end library for your c++ Qt projects.
irequest.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2023-2026 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8
9#ifndef IREQUEST_H
10#define IREQUEST_H
11
12#include "qTbot/global.h"
13
14#include <QByteArray>
15#include <QMap>
16#include <QString>
17#include <QHttpMultiPart>
18
19#define REQUEST_UPLOAD_FILE_KEY "_file_"
20
21namespace qTbot {
22
26typedef QHash<QString, QSharedPointer<QJsonObject>> ExtraJsonObjects;
27
32class QTBOT_EXPORT iRequest
33{
34public:
38 iRequest();
39
57
88
93 virtual QString makeUpload() const;
94
99 virtual QString baseAddress() const = 0;
100
105 virtual RequestMethod method() const = 0;
106
111 const QString& request() const;
112
117 void setRequest(const QString &newRequest);
118
123 const QMap<QString, QVariant> &args() const;
124
130 void addArg(const QString& key, const QVariant& val);
131
136 void setArgs(const QMap<QString, QVariant> &newArgs);
137
143 QString argsToUrl() const;
144
151 QSharedPointer<QHttpMultiPart> argsToMultipartFormData() const;
152
158
163 void setPriority(RequestPriority newPriority);
164
165private:
166 QString _request;
167 QMap<QString, QVariant> _args;
169
170};
171
172}
173#endif // IREQUEST_H
QString argsToUrl() const
argsToUrl This method converts the arguments to a URL string.
Definition irequest.cpp:42
RequestMethod
RequestMethod This is the list of supported request types.
Definition irequest.h:43
@ Post
Post general post request.
Definition irequest.h:51
@ Upload
Upload this is a post request to upload big data to telegram.
Definition irequest.h:55
@ Get
Get general get request, all request data is sent as a url line.
Definition irequest.h:47
RequestPriority priority() const
priority This is the priority of executing this request on the client.
Definition irequest.cpp:94
void setRequest(const QString &newRequest)
setRequest sets a custom request command
Definition irequest.cpp:106
const QMap< QString, QVariant > & args() const
args This method returns the the current list of arguments
Definition irequest.cpp:30
const QString & request() const
request Returns the current request command.
Definition irequest.cpp:102
void setArgs(const QMap< QString, QVariant > &newArgs)
setArgs For some requests the list of arguments is possible to build only after the constructor.
Definition irequest.cpp:38
void addArg(const QString &key, const QVariant &val)
addArg This method pushes a new argument to the arguments list
Definition irequest.cpp:34
virtual QString baseAddress() const =0
baseAddress This method returns the base domain of the remote server.
virtual RequestMethod method() const =0
method returns the method of the request.
iRequest()
iRequest default constructor.
Definition irequest.cpp:15
void setPriority(RequestPriority newPriority)
setPriority This method sets a new priority for the request.
Definition irequest.cpp:98
RequestPriority
The RequestPriority enum This is the list of request execution priorities on the client side.
Definition irequest.h:61
@ NoPriority
NoPriority the request has no priority. It will be executed last.
Definition irequest.h:65
@ HighPriority
HighPriority the request has a high priority.
Definition irequest.h:77
@ NormalPriority
NormalPriority the request has a normal priority. This is the default value.
Definition irequest.h:73
@ MaxPriorityValue
MaxPriorityValue the maximum value of the priority.
Definition irequest.h:86
@ UngeredPriority
UngeredPriority the request has an urgent priority. It will be executed first.
Definition irequest.h:81
@ LowPriority
LowPriority the request has a low priority.
Definition irequest.h:69
QSharedPointer< QHttpMultiPart > argsToMultipartFormData() const
argsToMultipartFormData This method generates multipart/form-data request data.
Definition irequest.cpp:58
QHash< QString, QSharedPointer< QJsonObject > > ExtraJsonObjects
ExtraJsonObjects hash map of the extra objects of the message.
Definition irequest.h:26