-
Notifications
You must be signed in to change notification settings - Fork 12
/
contract.cpp
62 lines (55 loc) · 1.59 KB
/
contract.cpp
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
#include "contract.h"
gecko::web::response gecko::contractFunctions::getCoinInfoFromContract(REQUIRED std::string id, REQUIRED std::string contract_address) {
cpr::Response r = this->request("coins/" + id + "/contract/" + contract_address, NULL);
return {
{r.text},
{std::to_string(r.status_code)},
{r.url.str()},
{r}
};
}
gecko::web::response gecko::contractFunctions::getContractMarketHistory(
REQUIRED std::string id, REQUIRED std::string contract_address,
REQUIRED std::string vs_currency, REQUIRED std::string days) {
cpr::Parameters p = gecko::web::buildParameters(
gecko::web::__buildStringParameters(
Strings {
{"vs_currency", vs_currency},
{"days", days}
}
),
NULL,
NULL,
NULL
);
cpr::Response r = this->request("coins/" + id + "/contract/" + contract_address + "/market_chart", &p);
return {
{r.text},
{std::to_string(r.status_code)},
{r.url.str()},
{r}
};
}
gecko::web::response gecko::contractFunctions::getContractMarketHistoryWithinRange(
REQUIRED std::string id, REQUIRED std::string contract_address,
REQUIRED std::string vs_currency, REQUIRED std::string to, REQUIRED std::string from) {
cpr::Parameters p = gecko::web::buildParameters(
gecko::web::__buildStringParameters(
Strings {
{"vs_currency", vs_currency},
{"to", to},
{"from", from}
}
),
NULL,
NULL,
NULL
);
cpr::Response r = this->request("coins/" + id + "/contract/" + contract_address + "/market_chart/range", &p);
return {
{r.text},
{std::to_string(r.status_code)},
{r.url.str()},
{r}
};
}