Skip to content

Commit d9dd69d

Browse files
authored
Merge pull request #15 from Dan-Tan/update-endpoints
Update endpoints
2 parents e9f827a + 2f21e74 commit d9dd69d

28 files changed

+27959
-1079
lines changed

CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,44 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55

66
set(CMAKE_CXX_STANDARD 20)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8-
set(GCC_CXX_FLAGS ${GCC_CXX_FLAGS} "-static-libgcc -static-libstdc++ -static -ggdb3 -O3")
8+
IF (DEBUG_MODE)
9+
set(GCC_CXX_FLAGS ${GCC_CXX_FLAGS} "-static-libgcc -static-libstdc++ -static -ggdb3 -O0")
10+
ELSE(DEBUG_MODE)
11+
set(GCC_CXX_FLAGS ${GCC_CXX_FLAGS} "-static-libgcc -static-libstdc++ -static -ggdb3 -O3")
12+
ENDIF(DEBUG_MODE)
913

1014
find_package(Catch2 3 REQUIRED)
1115

12-
add_subdirectory(src/riot-cpp)
16+
IF (URL_TESTS)
17+
add_executable(url_tests test/url_tests.cpp)
18+
target_link_libraries(url_tests Catch2::Catch2WithMain)
19+
ENDIF(URL_TESTS)
1320

21+
add_subdirectory(src/riot-cpp)
1422

1523
target_compile_options(riot-cpp PRIVATE -fsanitize=address -static-libasan)
1624
target_link_options(riot-cpp PRIVATE -fsanitize=address -static-libasan)
1725

18-
1926
add_executable(client_tests test/client_tests.cpp test/simdjson.cpp)
2027
target_link_libraries(client_tests riot-cpp)
2128
target_link_libraries(client_tests Catch2::Catch2WithMain)
2229

2330
target_compile_options(client_tests PRIVATE -fsanitize=address -static-libasan)
2431
target_link_options(client_tests PRIVATE -fsanitize=address -static-libasan)
2532

26-
add_executable(rate_tests test/Rate_Tests.cpp)
27-
target_link_libraries(rate_tests riot-cpp)
28-
target_link_libraries(rate_tests Catch2::Catch2WithMain)
2933

30-
target_compile_options(rate_tests PRIVATE -fsanitize=address -static-libasan)
31-
target_link_options(rate_tests PRIVATE -fsanitize=address -static-libasan)
34+
IF(BUILD_TESTING)
35+
add_executable(rate_tests test/Rate_Tests.cpp)
36+
target_link_libraries(rate_tests riot-cpp)
37+
target_link_libraries(rate_tests Catch2::Catch2WithMain)
38+
39+
target_compile_options(rate_tests PRIVATE -fsanitize=address -static-libasan)
40+
target_link_options(rate_tests PRIVATE -fsanitize=address -static-libasan)
41+
42+
add_executable(util_tests test/type_tests.cpp)
43+
target_link_libraries(util_tests riot-cpp)
44+
target_link_libraries(util_tests Catch2::Catch2WithMain)
3245

46+
target_compile_options(util_tests PRIVATE -fsanitize=address -static-libasan)
47+
target_link_options(util_tests PRIVATE -fsanitize=address -static-libasan)
48+
ENDIF(BUILD_TESTING)

src/riot-cpp/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ set(CXX_STANDARD_REQUIRED TRUE)
33

44
find_package(CURL REQUIRED)
55

6-
add_library(riot-cpp STATIC client/client.cpp query/query.cpp handling/structures/request_history.cpp handling/handlers.cpp logging/logger.cpp)
6+
add_library(riot-cpp STATIC client/client.cpp
7+
handling/rate_hierachy.cpp
8+
handling/handlers.cpp
9+
handling/rate_handler.cpp
10+
handling/region_count.cpp
11+
logging/logger.cpp
12+
types/region_enums.cpp)
713

814
target_include_directories(riot-cpp PRIVATE ${CURL_INCLUDE_DIRS})
915

src/riot-cpp/client/client.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <regex>
1414
#include <cstring>
1515
#include "client.h"
16-
16+
namespace riotcpp {
1717
namespace client {
1818

1919
using func_type = std::function<std::unique_ptr<json_text>(std::shared_ptr<query::query>)>;
@@ -47,28 +47,29 @@ namespace client {
4747
logger(path_to_log, report_level, verbose_logging),
4848
request_handler(&(this->logger)),
4949
endpoint_call(std::bind_front(&RiotApiClient::query, this)),
50-
Account(&this->endpoint_call),
51-
Champion_Mastery(&this->endpoint_call),
52-
Champion(&this->endpoint_call),
53-
Clash(&this->endpoint_call),
54-
League_Exp(&this->endpoint_call),
50+
Account(&this->endpoint_call),
51+
Champion_Mastery(&this->endpoint_call),
52+
Champion(&this->endpoint_call),
53+
Clash(&this->endpoint_call),
54+
League_exp(&this->endpoint_call),
5555
League(&this->endpoint_call),
5656
Lol_Challenges(&this->endpoint_call),
5757
Lol_Status(&this->endpoint_call),
5858
Lor_Match(&this->endpoint_call),
5959
Lor_Ranked(&this->endpoint_call),
6060
Lor_Status(&this->endpoint_call),
6161
Match(&this->endpoint_call),
62-
Summoner(&this->endpoint_call),
62+
Spectator_Tft(&this->endpoint_call),
6363
Spectator(&this->endpoint_call),
64+
Summoner(&this->endpoint_call),
6465
Tft_League(&this->endpoint_call),
6566
Tft_Match(&this->endpoint_call),
6667
Tft_Status(&this->endpoint_call),
6768
Tft_Summoner(&this->endpoint_call),
6869
Val_Content(&this->endpoint_call),
6970
Val_Match(&this->endpoint_call),
7071
Val_Ranked(&this->endpoint_call),
71-
Val_Status(&this->endpoint_call){
72+
Val_Status(&this->endpoint_call) {
7273
curl_global_init(CURL_GLOBAL_ALL);
7374

7475
// initialised libcurl handle and header
@@ -138,7 +139,7 @@ namespace client {
138139

139140
request->response_content->clear();
140141

141-
curl_easy_setopt(this->easy_handle, CURLOPT_URL, request->url.data());
142+
curl_easy_setopt(this->easy_handle, CURLOPT_URL, request->url.get());
142143
curl_easy_setopt(this->easy_handle, CURLOPT_HTTPGET, 1);
143144
curl_easy_setopt(this->easy_handle, CURLOPT_HTTPHEADER, this->header);
144145

@@ -181,7 +182,7 @@ namespace client {
181182

182183
std::unique_ptr<json_text> RiotApiClient::query(std::shared_ptr<query::query> request) {
183184

184-
this->logger << logging::LEVEL::DEBUG << "--Query Call--" << request->url << 0;
185+
this->logger << logging::LEVEL::DEBUG << "--Query Call--" << std::string(request->url.get()) << 0;
185186

186187
while (this->request_handler.review_request(request)) {
187188
if (request->last_response == 200) {
@@ -200,3 +201,4 @@ namespace client {
200201
return std::move(request->response_content);
201202
}
202203
}
204+
}

src/riot-cpp/client/client.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,50 @@
66
#include <string_view>
77
#include <unordered_map>
88
#include <memory>
9-
#include "../query/query.h"
9+
#include "../query/endpoints.h"
1010
#include "../handling/handlers.h"
1111
#include "../logging/logger.h"
1212
#include <functional>
13-
13+
namespace riotcpp {
1414
namespace client {
1515

1616
using json_text = std::vector<char>;
1717

1818
using opt_args = std::pair<std::string, std::string>;
1919

2020
class RiotApiClient {
21-
private:
22-
;
23-
2421
public:
2522
RiotApiClient(std::string path_to_config, std::string path_to_log, logging::LEVEL report_level = logging::LEVEL::INFO, bool verbose_logging = false);
2623
~RiotApiClient();
24+
25+
const query::Account_v1 Account;
26+
const query::Champion_Mastery_v4 Champion_Mastery;
27+
const query::Champion_v3 Champion;
28+
const query::Clash_v1 Clash;
29+
const query::League_exp_v4 League_exp;
30+
const query::League_v4 League;
31+
const query::Lol_Challenges_v1 Lol_Challenges;
32+
const query::Lol_Status_v4 Lol_Status;
33+
const query::Lor_Match_v1 Lor_Match;
34+
const query::Lor_Ranked_v1 Lor_Ranked;
35+
const query::Lor_Status_v1 Lor_Status;
36+
const query::Match_v5 Match;
37+
const query::Spectator_Tft_v5 Spectator_Tft;
38+
const query::Spectator_v5 Spectator;
39+
const query::Summoner_v4 Summoner;
40+
const query::Tft_League_v1 Tft_League;
41+
const query::Tft_Match_v1 Tft_Match;
42+
const query::Tft_Status_v1 Tft_Status;
43+
const query::Tft_Summoner_v1 Tft_Summoner;
44+
const query::Val_Content_v1 Val_Content;
45+
const query::Val_Match_v1 Val_Match;
46+
const query::Val_Ranked_v1 Val_Ranked;
47+
const query::Val_Status_v1 Val_Status;
2748

28-
query::ACCOUNT_V1 Account;
29-
query::CHAMPION_MASTERY_V4 Champion_Mastery;
30-
query::CHAMPION_V3 Champion;
31-
query::CLASH_V1 Clash;
32-
query::LEAGUE_EXP_V4 League_Exp;
33-
query::LEAGUE_V4 League;
34-
query::LOL_CHALLENGES_V1 Lol_Challenges;
35-
query::LOL_STATUS Lol_Status;
36-
query::LOR_MATCH_V1 Lor_Match;
37-
query::LOR_RANKED_V1 Lor_Ranked;
38-
query::LOR_STATUS_V1 Lor_Status;
39-
query::MATCH_V5 Match;
40-
query::SUMMONER_V4 Summoner;
41-
query::SPECTATOR_V4 Spectator;
42-
query::TFT_LEAGUE_V1 Tft_League;
43-
query::TFT_MATCH_V1 Tft_Match;
44-
query::TFT_STATUS_V1 Tft_Status;
45-
query::TFT_SUMMONER_V1 Tft_Summoner;
46-
query::VAL_CONTENT_V1 Val_Content;
47-
query::VAL_MATCH_V1 Val_Match;
48-
query::VAL_RANKED_V1 Val_Ranked;
49-
query::VAL_STATUS_V1 Val_Status;
5049

5150
protected:
5251

53-
handler::RequestHandler request_handler;
52+
rate::RequestHandler request_handler;
5453
logging::Logger logger;
5554

5655
private:
@@ -63,3 +62,4 @@ namespace client {
6362
struct curl_slist *header = nullptr;
6463
};
6564
}
65+
}

0 commit comments

Comments
 (0)