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/include | |
| 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/include')
| -rw-r--r-- | battleNetApi/include/hearthstoneApi.hpp | 11 | ||||
| -rw-r--r-- | battleNetApi/include/tokenPool.hpp | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/battleNetApi/include/hearthstoneApi.hpp b/battleNetApi/include/hearthstoneApi.hpp index c3fbfac..ecf785a 100644 --- a/battleNetApi/include/hearthstoneApi.hpp +++ b/battleNetApi/include/hearthstoneApi.hpp @@ -8,17 +8,14 @@ using json = nlohmann::json; class HearthstoneApi { public: - HearthstoneApi(const Token &iToken); - HearthstoneApi(Token &&iToken); - json makeApiRequest(const std::string &iUrl) const; - std::vector<json> makeApiRequest(const std::vector<std::string> &iUrls) const; - void downloadAllCards(ApiUrl &iApiUrl, const std::string &iOutputJsonPath) const; + static json makeApiRequest(const std::string &iUrl, const std::string &iTokenText); + static std::vector<json> makeApiRequest(const std::vector<std::string> &iUrls, const std::string &iTokenText); + static json downloadCards(ApiUrl &iApiUrl, Token &iToken); private: - std::string authorizationHeader() const; + static std::string authorizationHeader(const std::string &iTokenText); static size_t curlCallbackStringOutput(void *iContent, size_t iSize, size_t iNmemb, std::string *iS); - Token mToken; std::string mAuthorizationHeader; //<! Bearer authorization string for OAuth 2.0 header friend class HearthstoneApiMock; diff --git a/battleNetApi/include/tokenPool.hpp b/battleNetApi/include/tokenPool.hpp new file mode 100644 index 0000000..6aa2b15 --- /dev/null +++ b/battleNetApi/include/tokenPool.hpp @@ -0,0 +1,16 @@ +#include <queue> +#include <token.hpp> + +class TokenPool { + private: + TokenPool() = default; + TokenPool(const TokenPool &) = delete; + TokenPool(TokenPool &&) = delete; + TokenPool &operator=(const TokenPool &) = delete; + TokenPool &operator=(TokenPool &&) = delete; + static std::queue<Token> mTokenContainer; + + public: + static void fillTokenSource(const std::string &iJsonPath); + static std::optional<std::string> unusedToken(); +}; |
