summaryrefslogtreecommitdiff
path: root/subprojects/battleNetApi/include/hearthstoneApi.hpp
diff options
context:
space:
mode:
authorAotrix <[email protected]>2025-11-17 13:30:23 +0100
committerAotrix <[email protected]>2025-11-17 13:30:23 +0100
commit9dab564d3aaabda88efda5e3289392d0be716084 (patch)
tree4d2d0188119ba33f29c0dc6c362c26a47a9e637d /subprojects/battleNetApi/include/hearthstoneApi.hpp
parentf78e3e1428f59fb96cb02cf6fbaad692a582f9d5 (diff)
changed subprojects to submodules
Diffstat (limited to 'subprojects/battleNetApi/include/hearthstoneApi.hpp')
-rw-r--r--subprojects/battleNetApi/include/hearthstoneApi.hpp43
1 files changed, 0 insertions, 43 deletions
diff --git a/subprojects/battleNetApi/include/hearthstoneApi.hpp b/subprojects/battleNetApi/include/hearthstoneApi.hpp
deleted file mode 100644
index c11acc7..0000000
--- a/subprojects/battleNetApi/include/hearthstoneApi.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-#include "token.hpp"
-#include <iostream>
-#include <regex>
-#include <string>
-
-class HearthstoneApi {
- public:
- HearthstoneApi(Token &&iToken);
- std::uint64_t numberOfCards(const std::string &iApiResponse) const;
-
- private:
- std::string authorizationHeader();
- std::string makeApiRequest(const std::string &iUrl) const;
- static size_t curlCallbackStringOutput(void *iContent, size_t iSize, size_t iNmemb, std::string *iS);
-
- /**
- * @brief
- * @param[in] iJsonContent The std::string which contains Json (Battle.net API response for instance)
- * @param[in] iKeyValueRegex The regex used to retrieve value from (key, value) pair
- * An example: "\"cardCount\":(\\d+)"
- */
- template <typename T> T valueInJson(const std::string &iJsonContent, const std::string &iKeyValueRegex) const {
- const std::regex iRegex{iKeyValueRegex};
- std::smatch aMatches;
- if (std::regex_search(iJsonContent, aMatches, iRegex)) {
- const std::string kValueString{aMatches[1].str()};
- T aValue;
- const auto kConversionStatus =
- std::from_chars(kValueString.data(), kValueString.data() + kValueString.size(), aValue);
- if (kConversionStatus.ec == std::errc{}) {
- return aValue;
- }
- }
- std::cerr << std::format("Unable to find value with regex: '{}'\n", iKeyValueRegex);
- return 0;
- }
-
- Token mToken;
- std::string mAuthorizationHeader; //<! Bearer authorization string for OAuth 2.0 header
-
- friend class HearthstoneApiMock;
-};