1 | #pragma once |
---|---|
2 | |
3 | #include <QObject> |
4 | |
5 | #include <QSharedPointer> |
6 | |
7 | class QNetworkAccessManager; |
8 | class QNetworkReply; |
9 | class QJsonDocument; |
10 | |
11 | namespace Jenkins |
12 | { |
13 | class IFetcher : public QObject |
14 | { |
15 | Q_OBJECT |
16 | public: |
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 | |
29 | protected: |
30 | IFetcher::Config mConfig; |
31 | |
32 | virtual void get(const QString &urlStr, bool customUrl = false) final; |
33 | |
34 | private: |
35 | virtual void processReply() final; |
36 | virtual void processData(const QJsonDocument &json) = 0; |
37 | }; |
38 | } |
39 |