blob: 43245d840a228e403f2b7d1886728cd13656a6de (
plain)
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
|
#include "apiUrl.hpp"
#include <hearthstoneApi.hpp>
#include <iostream>
#include <stdexcept>
int main(int argc, char *argv[]) {
if (argc < 3) {
// Example of parameters:
// ./build/downloadCards tests/resources/credentials.json build/output.json
throw std::invalid_argument("<path_to_executable_dir>/<executable_name> <path_to_credentials> <output_path>");
}
std::string aCredentialsFilePath{argv[1]};
Token aToken(aCredentialsFilePath);
HearthstoneApi aHearthstoneApi(aToken);
std::string aOutputPath{argv[2]};
if (argc < 4) {
const std::string kContentType{"cards"};
const std::string kRegion{"eu"};
ApiUrl aApiUrl(kContentType, kRegion);
aApiUrl.setLocale("fr_FR");
aApiUrl.setGameMode("constructed");
aApiUrl.setPageSize("100");
std::cout << "Downloading cards...\n";
aHearthstoneApi.downloadAllCards(aApiUrl, aOutputPath);
std::cout << "Download done.\n";
} else {
// TODO: retrieve config from JSON file
}
return 0;
}
|