-
Notifications
You must be signed in to change notification settings - Fork 3
/
restclient.h
86 lines (69 loc) · 2.39 KB
/
restclient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef RESTCLIENT_H
#define RESTCLIENT_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
class restClient : public QObject
{
Q_OBJECT
public:
explicit restClient(QObject *parent = nullptr);
void getBalance();
void getPerformance();
void getStatus();
void getProfit();
void getHistory();
void postStart();
void postStop();
void postStopBuy();
void postReloadConf();
void postForceSell(const int id);
void postForceSellAll();
void postForceBuy(const QString& pair, double amount);
void getShowConfig();
void setURLPort(const QString& url, const int& port){_url =QString("http://%1:%2").arg(url).arg(port);};
void setCredentials(const QString& name, const QString& password)
{
_authHelper = "Basic " + QByteArray(QString("%1:%2").arg(name).arg(password).toStdString().c_str()).toBase64();
};
private:
QNetworkAccessManager* _netMngrBalance;
QNetworkAccessManager* _netMngrPerformance;
QNetworkAccessManager* _netMngrStatus;
QNetworkAccessManager* _netMngrProfit;
QNetworkAccessManager* _netMngrTradeHistory;
QNetworkAccessManager* _netMngrStart;
QNetworkAccessManager* _netMngrStop;
QNetworkAccessManager* _netMngrStopBuy;
QNetworkAccessManager* _netMngrReloadConf;
QNetworkAccessManager* _netMngrForceSell;
QNetworkAccessManager* _netMngrForceBuy;
QNetworkAccessManager* _netMngrShowConfig;
QString _url;
QByteArray _authHelper;
public slots:
void replyBalance(QNetworkReply* reply);
void replyPerformance(QNetworkReply* reply);
void replyStatus(QNetworkReply* reply);
void replyProfit(QNetworkReply* reply);
void replyTradesHistory(QNetworkReply* reply);
void replyStart(QNetworkReply* reply);
void replyStop(QNetworkReply* reply);
void replyStopBuy(QNetworkReply* reply);
void replyReloadConf(QNetworkReply* reply);
void replyForceSell(QNetworkReply* reply);
void replyForceBuy(QNetworkReply* reply);
void replyShowConfig(QNetworkReply* reply);
signals:
void balanceSignal(QJsonDocument);
void performanceSignal(QJsonDocument);
void statusSignal(QJsonDocument);
void profitSignal(QJsonDocument);
void historySignal(QJsonDocument);
void showConfigSignal(const QString);
};
#endif // RESTCLIENT_H