diff options
| author | Aotrix <[email protected]> | 2025-11-16 21:07:44 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2025-11-16 21:07:44 +0100 |
| commit | e006ece3289c848ca2975f06386d6a2a51bdb67f (patch) | |
| tree | 1d72ae49b6a14cd43b3dec06ff78a7ae6d628f3c /subprojects/battleNetApi/src/hearthstoneApi.cpp | |
| parent | 832e276e94d4d5a30885e6e352ffdd19f4f16f04 (diff) | |
Refactored JSON value retrieval
Diffstat (limited to 'subprojects/battleNetApi/src/hearthstoneApi.cpp')
| -rw-r--r-- | subprojects/battleNetApi/src/hearthstoneApi.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/subprojects/battleNetApi/src/hearthstoneApi.cpp b/subprojects/battleNetApi/src/hearthstoneApi.cpp index b6eaf71..c34e6ad 100644 --- a/subprojects/battleNetApi/src/hearthstoneApi.cpp +++ b/subprojects/battleNetApi/src/hearthstoneApi.cpp @@ -4,11 +4,10 @@ HearthstoneApi::HearthstoneApi(Token &&iToken) : mToken(iToken), mAuthorizationHeader(authorizationHeader()) {} -std::uint64_t HearthstoneApi::numberOfCards() { - // TODO: implement logic - return 123456; +std::uint64_t HearthstoneApi::numberOfCards(const std::string &iApiResponse) const { + const std::string aCardCountRegex{"\"cardCount\":(\\d+)"}; + return valueInJson<std::uint64_t>(iApiResponse, aCardCountRegex); } - std::string HearthstoneApi::authorizationHeader() { return std::format("Authorization: Bearer {}", mToken.toString()); } size_t HearthstoneApi::curlCallbackStringOutput(void *iContent, size_t iSize, size_t iNmemb, std::string *iS) { |
