diff --git a/Cargo.lock b/Cargo.lock index 6165bd2..81e6b4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,8 +3,8 @@ version = 3 [[package]] -name = "apex_legends" -version = "0.1.2" +name = "apex_legends_api" +version = "0.1.4" dependencies = [ "dotenv", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 188425e..7f3b9fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,16 @@ [package] -name = "apex_legends" +name = "apex_legends_api" description = "An API wrapper for the MozambiqueHe.re Apex Legends API." -version = "0.1.2" +version = "0.1.4" edition = "2018" -author = "KasprDev " -repository = "https://github.com/KasprDev/Apex-Legends-API-Rust" +authors = ["KasprDev ", "margual56 "] +repository = "https://github.com/margual56/Apex-Legends-API-Rust" keywords = ["apex_legends", "apex", "game", "video_game", "api"] categories = ["api-bindings", "asynchronous"] -exclude = ["src/main.rs"] -license = "MIT OR Apache-2.0" +exclude = ["src/main.rs", ".github/"] +license = "MIT" +readme = "README.md" + [dependencies] tokio = { version = "1.0", features = ["full"] } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..28d1eb1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Marcos GutiƩrrez Alonso + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 40a0a44..1d1112c 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,20 @@ use apex_legends; #[tokio::main] async fn main() { - match apex_legends::get_user("HeyImLifeline".to_string(), "your_api_key").await { + match apex_legends::get_user_retry("HeyImLifeline".to_string(), "your_api_key", true).await { Ok(data) => println!("You are level {}.", data.global.level), - Err(e) => { - println!("there was an error!: {}", e) - } + Err(e) => println!("There was an error!: {}", e) } } ``` I have no affiliation with Apex Legends, EA, or Apex Legends Status. + +## A note about the failing test + +This is a known issue in the API. It has a rate limit, so it should return code 429 when the limit is reached. Instead, it returns 200 OK, so the library immediately retries and, unsurprisingly, it fails. + + +# Authors + +The original author is [KasprDev](https://github.com/KasprDev), and this is a fork with some improvements for stability and extra features. Some of them were upstreamed, but not all of them as of yet. \ No newline at end of file diff --git a/src/http.rs b/src/http.rs index acd5882..0c3c9dc 100644 --- a/src/http.rs +++ b/src/http.rs @@ -19,6 +19,7 @@ pub async fn get_request(url: String) -> Result Result { let client = reqwest::Client::new(); diff --git a/tests/test.rs b/tests/test.rs index a22356f..5f859b9 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use apex_legends::data_types; + use apex_legends_api::data_types; use std::env; fn print_data(res: Result, f: fn(T) -> String) -> bool { @@ -27,7 +27,7 @@ mod tests { assert!( print_data::( - apex_legends::get_user_retry(String::from(&user_name), &api_key, true).await, + apex_legends_api::get_user_retry(String::from(&user_name), &api_key, true).await, |data| { format!( "You are level {}, and you have {} kills.", @@ -40,7 +40,7 @@ mod tests { assert!( print_data::( - apex_legends::get_user_retry(String::from(&user_name), &api_key, true).await, + apex_legends_api::get_user_retry(String::from(&user_name), &api_key, true).await, |data| { format!( "You are level {}, and you have {} kills.", @@ -60,8 +60,12 @@ mod tests { assert!( print_data::( - apex_legends::get_uid_from_username_retry(String::from(&user_name), &api_key, true) - .await, + apex_legends_api::get_uid_from_username_retry( + String::from(&user_name), + &api_key, + true + ) + .await, |data| format!("Your UID is {}", data.uid), ), "get_uid_from_username_retry" @@ -69,8 +73,12 @@ mod tests { assert!( print_data::( - apex_legends::get_uid_from_username_retry(String::from(&user_name), &api_key, true) - .await, + apex_legends_api::get_uid_from_username_retry( + String::from(&user_name), + &api_key, + true + ) + .await, |data| format!("Your UID is {}", data.uid), ), "get_uid_from_username_retry" @@ -85,7 +93,7 @@ mod tests { assert!( print_data::( - apex_legends::get_map_rotation_retry(&api_key, true).await, + apex_legends_api::get_map_rotation_retry(&api_key, true).await, |data| { format!( "The current ranked map is {}", @@ -97,7 +105,7 @@ mod tests { ); assert!( print_data::( - apex_legends::get_map_rotation_retry(&api_key, true).await, + apex_legends_api::get_map_rotation_retry(&api_key, true).await, |data| { format!( "The current ranked map is {}",