1#pragma once
2
3#include <QObject>
4
5#include <QSharedPointer>
6
7class QNetworkAccessManager;
8class QNetworkReply;
9class QJsonDocument;
10
11namespace Jenkins
12{
13class IFetcher : public QObject
14{
15 Q_OBJECT
16public:
17 struct Config
18 {
19 QString user;
20 QString token;
21 QSharedPointer<QNetworkAccessManager> accessManager;
22 };
23
24 explicit IFetcher(const IFetcher::Config &config, QObject *parent = nullptr);
25 ~IFetcher();
26
27 virtual void triggerFetch() = 0;
28
29protected:
30 IFetcher::Config mConfig;
31
32 virtual void get(const QString &urlStr, bool customUrl = false) final;
33
34private:
35 virtual void processReply() final;
36 virtual void processData(const QJsonDocument &json) = 0;
37};
38}
39