summaryrefslogtreecommitdiff
path: root/battleNetApi/src/main.cpp
blob: a1c64a37ad73d6d603fac7ddaa31e617c97237e8 (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
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
#include "apiUrl.hpp"
#include <hearthstoneApi.hpp>
#include <iostream>
#include <stdexcept>

class DownloadMethod {
  public:
    virtual void download() = 0;
};

class DefaultDownloadMethod : public DownloadMethod {
  public:
    void download() {
        std::cout << "OMG je suis une méthode de téléchargement !\n";
        //     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";
    }
};

class DownloaderContext {
  public:
    DownloaderContext() = default;
    DownloaderContext(std::unique_ptr<DownloadMethod> iDownloader) : mDownloader(std::move(iDownloader)) {};
    void setDownloader(std::unique_ptr<DownloadMethod> iDownloader) { mDownloader = std::move(iDownloader); }
    void download() {
        if (mDownloader) {
            mDownloader->download();
        } else {
            std::cerr << "No download method available in DownloaderContext\n";
        }
    }

  private:
    std::unique_ptr<DownloadMethod> mDownloader;
};

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]};

    DownloaderContext aDownloaderContext;
    if (argc < 4) {
        aDownloaderContext.setDownloader(std::make_unique<DefaultDownloadMethod>());
    } else {
        // TODO: retrieve config from JSON file
    }
    aDownloaderContext.download();

    return 0;
}