1// SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <Quotient/util.h>
7
8class QJsonObject;
9class QJsonArray;
10class QJsonDocument;
11class QIODevice;
12
13namespace Quotient {
14/**
15 * A simple wrapper that represents the request body.
16 * Provides a unified interface to dump an unstructured byte stream
17 * as well as JSON (and possibly other structures in the future) to
18 * a QByteArray consumed by QNetworkAccessManager request methods.
19 */
20class QUOTIENT_API RequestData {
21public:
22 // NOLINTBEGIN(google-explicit-constructor): that check should learn about
23 // explicit(false)
24 QUO_IMPLICIT RequestData(const QByteArray& a = {});
25 QUO_IMPLICIT RequestData(const QJsonObject& jo);
26 QUO_IMPLICIT RequestData(const QJsonArray& ja);
27 QUO_IMPLICIT RequestData(QIODevice* source);
28 // NOLINTEND(google-explicit-constructor)
29
30 QIODevice* source() const { return _source.get(); }
31
32private:
33 ImplPtr<QIODevice> _source;
34};
35} // namespace Quotient
36