-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.h
41 lines (33 loc) · 1.08 KB
/
api.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
#pragma once
#include <QNetworkAccessManager>
#include <QObject>
#include <functional>
using namespace Qt::Literals::StringLiterals;
struct Quote {
QString symbol;
QString response;
double open;
double high;
double low;
double price;
int volume;
QString latest_trading_day;
double previous_close;
double change;
QString change_percent;
QString updated_at;
friend QDebug operator<<(QDebug debug, const Quote& c)
{
QDebugStateSaver saver(debug);
debug.nospace() << "Quote(" << c.symbol << ", " << c.response << ", " << c.open << ", " << c.high << ", " << c.low << ", " << c.price << ", " << c.volume << ", " << c.latest_trading_day << ", " << c.previous_close << ", " << c.change << ", " << c.change_percent << ", " << c.updated_at << ")";
return debug;
}
};
namespace Api {
enum class CacheParam {
USE_NETWORK,
USE_CACHE
};
extern QNetworkAccessManager& getManager();
extern void getSymbol(const QString& symbol, const std::function<void(Quote&& quote)>&& callback, CacheParam = CacheParam::USE_CACHE);
};