summaryrefslogtreecommitdiff
path: root/battleNetApi/include
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-04-19 18:16:14 +0200
committerAotrix <[email protected]>2026-04-19 18:16:14 +0200
commitcc436cb44c60ef2485321e1e22b3ea0a59ee22af (patch)
treeb04464945278bcdc8915d8b3676b504a95e3f701 /battleNetApi/include
parent8837de4783b25255b6a1799be210c9e580dd2d4f (diff)
TokenPool now works
Diffstat (limited to 'battleNetApi/include')
-rw-r--r--battleNetApi/include/apiUrl.hpp18
-rw-r--r--battleNetApi/include/hearthstoneApi.hpp2
-rw-r--r--battleNetApi/include/token.hpp2
-rw-r--r--battleNetApi/include/tokenPool.hpp7
4 files changed, 23 insertions, 6 deletions
diff --git a/battleNetApi/include/apiUrl.hpp b/battleNetApi/include/apiUrl.hpp
index 881e593..e936b6c 100644
--- a/battleNetApi/include/apiUrl.hpp
+++ b/battleNetApi/include/apiUrl.hpp
@@ -1,4 +1,5 @@
#pragma once
+#include <cstdint>
#include <string>
#include <unordered_map>
@@ -10,12 +11,27 @@ class ApiUrl {
void setLocale(const std::string &iLocale);
void setGameMode(const std::string &iGameMode);
void setPage(const std::string &iPage);
+ void setPage(uint64_t iPage);
void setPageSize(const std::string &iPageSize);
- void setValue(const std::string &iKey, const std::string &iValue);
+ void setPageSize(uint64_t iPageSize);
+
+ bool hasRegion() const;
+ bool hasLocale() const;
+ bool hasGameMode() const;
+ bool hasPage() const;
+ bool hasPageSize() const;
+
std::string text() const;
private:
+ static constexpr std::string kLOCALE_KEY{"locale"};
+ static constexpr std::string kGAME_MODE_KEY{"gameMode"};
+ static constexpr std::string kPAGE_KEY{"page"};
+ static constexpr std::string kPAGE_SIZE_KEY{"pageSize"};
std::string mContentType;
std::string mRegion;
std::unordered_map<std::string, std::string> aParameters;
+
+ void setValue(const std::string &iKey, const std::string &iValue);
+ bool hasValue(const std::string &iKey) const;
};
diff --git a/battleNetApi/include/hearthstoneApi.hpp b/battleNetApi/include/hearthstoneApi.hpp
index f2bdf04..59cd336 100644
--- a/battleNetApi/include/hearthstoneApi.hpp
+++ b/battleNetApi/include/hearthstoneApi.hpp
@@ -11,7 +11,7 @@ class HearthstoneApi {
static json makeApiRequest(const ApiUrl &iApiUrl, const std::string &iTokenText);
static std::vector<json> makeApiRequest(const std::vector<ApiUrl> &iApiUrls, 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);
+ static json downloadCards(ApiUrl iApiUrl, const Token &iToken);
private:
static std::string authorizationHeader(const std::string &iTokenText);
diff --git a/battleNetApi/include/token.hpp b/battleNetApi/include/token.hpp
index 23d1f49..bcb4926 100644
--- a/battleNetApi/include/token.hpp
+++ b/battleNetApi/include/token.hpp
@@ -5,7 +5,7 @@
class Token {
public:
- Token(const std::string &iTokenFilePath);
+ explicit Token(const std::string &iTokenFilePath);
std::string text() const;
const bool hasExpired() const;
void updateToken();
diff --git a/battleNetApi/include/tokenPool.hpp b/battleNetApi/include/tokenPool.hpp
index 6f5dffc..0b1e4cc 100644
--- a/battleNetApi/include/tokenPool.hpp
+++ b/battleNetApi/include/tokenPool.hpp
@@ -3,7 +3,7 @@
#include <queue>
#include <token.hpp>
-static std::queue<Token> mTokenContainer;
+static std::queue<Token> aTokenContainer;
class TokenPool {
private:
@@ -14,6 +14,7 @@ class TokenPool {
TokenPool &operator=(TokenPool &&) = delete;
public:
- static void fillTokenSource(const std::string &iJsonPath);
- static std::optional<std::string> unusedToken();
+ static void feedTokenSource(const std::span<std::string> &iJsonPaths);
+ static void feedTokenSource(const std::string &iJsonPath);
+ static std::optional<Token> availableToken();
};