diff options
| author | Aotrix <[email protected]> | 2026-03-27 18:48:55 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-03-27 18:48:55 +0100 |
| commit | f01072eb4166fc68f59519ebf84de46e7386abf5 (patch) | |
| tree | 72885a1d6296b787bcd2d19d45ccce4777274717 /battleNetApi/src/main.cpp | |
| parent | a20c4abc424404518bcb656a3f22f43991a6c164 (diff) | |
Generate json card lists with static methods
Instead of creating a useless instance of HearthstoneApi class, calls
static methods.
Diffstat (limited to 'battleNetApi/src/main.cpp')
| -rw-r--r-- | battleNetApi/src/main.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/battleNetApi/src/main.cpp b/battleNetApi/src/main.cpp index 3c36a8d..7f2450e 100644 --- a/battleNetApi/src/main.cpp +++ b/battleNetApi/src/main.cpp @@ -1,27 +1,34 @@ #include "apiUrl.hpp" #include <hearthstoneApi.hpp> #include <iostream> -#include <stdexcept> +#include <print> +#include <tokenPool.hpp> class DownloadMethod { public: virtual void download() = 0; + virtual ~DownloadMethod() = default; }; 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"; - } + DefaultDownloadMethod() = default; + ~DefaultDownloadMethod() = default; + void download() override { + 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::println("Downloading cards..."); + TokenPool::fillTokenSource("tests/resources/credentials.json"); + std::optional<Token> aToken{TokenPool::unusedToken()}; + if (aToken.has_value()) { + HearthstoneApi::downloadCards(aApiUrl, aToken.value()); + std::println("Download done."); + } + }; }; class DownloaderContext { @@ -61,5 +68,7 @@ int main(int argc, char *argv[]) { } aDownloaderContext.download(); + // std::ofstream aOutputJson(iOutputJsonPath); + // aOutputJson << aMergedCards.dump(4); return 0; } |
