summaryrefslogtreecommitdiff
path: root/battleNetApi/src/main.cpp
blob: 4e3885b4e12eae08ebe9a762e892673b19526a02 (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
#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]};
    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";

    return 0;
}