1mod client;
6mod credentials;
7mod error;
8mod events;
9
10pub mod generated {
11 include!(concat!(env!("OUT_DIR"), "/lcu_endpoints.rs"));
12}
13
14pub use client::{
15 ConnectOptions, EndpointParams, LcuClient, PollEvent, PollOptions, ReadinessCheck,
16 RequestOptions,
17};
18pub use credentials::{Credentials, CredentialsSource};
19pub use error::{Error, Result};
20pub use events::{EventFilter, EventStream, LcuEvent};
21
22#[cfg(test)]
23mod tests {
24 use super::generated::{
25 ENDPOINTS, GET_LOL_SUMMONER_V1_CURRENT_SUMMONER, PUT_LOL_CHAT_V1_CONVERSATIONS_BY_ID,
26 SCHEMA_TITLE, SCHEMA_UPSTREAM_URL, SCHEMA_VERSION, TAGS, endpoints_for_tag, find_endpoint,
27 find_endpoint_by_operation_id, models,
28 };
29
30 #[test]
31 fn swagger_generates_lcu_endpoints() {
32 assert_eq!(SCHEMA_TITLE, "LCU SCHEMA");
33 assert!(!SCHEMA_VERSION.is_empty());
34 assert!(SCHEMA_UPSTREAM_URL.contains("dysolix/hasagi-types"));
35 assert!(ENDPOINTS.len() > 1_000);
36 assert!(ENDPOINTS.iter().any(|endpoint| {
37 endpoint.method == "GET" && endpoint.path == "/lol-summoner/v1/current-summoner"
38 }));
39 assert_eq!(
40 GET_LOL_SUMMONER_V1_CURRENT_SUMMONER.response_type,
41 Some("LolSummonerSummoner")
42 );
43 }
44
45 #[test]
46 fn swagger_generates_lcu_models() {
47 let summoner: models::LolSummonerSummoner = serde_json::from_value(serde_json::json!({
48 "accountId": 1,
49 "displayName": "steel",
50 "gameName": "steel",
51 "internalName": "steel",
52 "nameChangeFlag": false,
53 "percentCompleteForNextLevel": 50,
54 "privacy": "PUBLIC",
55 "profileIconId": 29,
56 "puuid": "puuid",
57 "rerollPoints": {
58 "currentPoints": 1,
59 "maxRolls": 2,
60 "numberOfRolls": 0,
61 "pointsCostToRoll": 250,
62 "pointsToReroll": 249
63 },
64 "summonerId": 2,
65 "summonerLevel": 30,
66 "tagLine": "NA1",
67 "unnamed": false,
68 "xpSinceLastLevel": 1,
69 "xpUntilNextLevel": 2
70 }))
71 .unwrap();
72
73 assert_eq!(summoner.summoner_id, 2);
74 assert_eq!(summoner.reroll_points.max_rolls, 2);
75 }
76
77 #[test]
78 fn swagger_generates_endpoint_discovery_helpers() {
79 let endpoint = find_endpoint("GET", "/lol-summoner/v1/current-summoner").unwrap();
80 assert_eq!(endpoint.operation_id, "GetLolSummonerV1CurrentSummoner");
81
82 let templated = find_endpoint("GET", "/lol-summoner/v1/summoners/123").unwrap();
83 assert_eq!(templated.path, "/lol-summoner/v1/summoners/{id}");
84
85 assert_eq!(
86 find_endpoint_by_operation_id("GetLolSummonerV1CurrentSummoner"),
87 Some(&GET_LOL_SUMMONER_V1_CURRENT_SUMMONER)
88 );
89
90 assert!(TAGS.contains(&"Plugin lol-summoner"));
91 assert!(
92 endpoints_for_tag("Plugin lol-summoner")
93 .any(|endpoint| endpoint.path == "/lol-summoner/v1/current-summoner")
94 );
95 }
96
97 #[test]
98 fn swagger_generates_typed_request_metadata() {
99 assert_eq!(
100 PUT_LOL_CHAT_V1_CONVERSATIONS_BY_ID.request_type,
101 Some("LolChatConversationResource")
102 );
103 assert_eq!(
104 PUT_LOL_CHAT_V1_CONVERSATIONS_BY_ID.response_type,
105 Some("LolChatConversationResource")
106 );
107
108 let _helper = super::generated::put_lol_chat_v1_conversations_by_id_with_body;
109 let _typed_helper = super::generated::put_lol_chat_v1_conversations_by_id_with_body_typed;
110 }
111}