#include "apiUrl.hpp" #include #include #include 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 iDownloader) : mDownloader(std::move(iDownloader)) {}; void setDownloadMethod(std::unique_ptr 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 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("/ // "); // } // std::string aCredentialsFilePath{argv[1]}; // Token aToken(aCredentialsFilePath); // HearthstoneApi aHearthstoneApi(aToken); // std::string aOutputPath{argv[2]}; DownloaderContext aDownloaderContext; if (argc < 4) { aDownloaderContext.setDownloadMethod(std::make_unique()); } else { // TODO: retrieve config from JSON file } aDownloaderContext.download(); return 0; }