Skip to content

Commit

Permalink
Updated and added missing metadata (#4)
Browse files Browse the repository at this point in the history
* Create LICENSE

* Fixed some metadata

* Run cargo fmt

* Added clarification on failing test
  • Loading branch information
margual56 authored Aug 24, 2022
1 parent 6d9b79f commit 0735693
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
repository = "https://github.com/KasprDev/Apex-Legends-API-Rust"
authors = ["KasprDev <[email protected]>", "margual56 <[email protected]>"]
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"] }
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub async fn get_request(url: String) -> Result<String, (reqwest::Error, Option<
}
}

#[allow(dead_code)]
pub async fn post_request(url: &str, body: String) -> Result<String, reqwest::Error> {
let client = reqwest::Client::new();

Expand Down
26 changes: 17 additions & 9 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -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<T>(res: Result<T, String>, f: fn(T) -> String) -> bool {
Expand All @@ -27,7 +27,7 @@ mod tests {

assert!(
print_data::<data_types::ApexUser>(
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.",
Expand All @@ -40,7 +40,7 @@ mod tests {

assert!(
print_data::<data_types::ApexUser>(
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.",
Expand All @@ -60,17 +60,25 @@ mod tests {

assert!(
print_data::<data_types::ApexProfile>(
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"
);

assert!(
print_data::<data_types::ApexProfile>(
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"
Expand All @@ -85,7 +93,7 @@ mod tests {

assert!(
print_data::<data_types::ApexMapRotation>(
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 {}",
Expand All @@ -97,7 +105,7 @@ mod tests {
);
assert!(
print_data::<data_types::ApexMapRotation>(
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 {}",
Expand Down

0 comments on commit 0735693

Please sign in to comment.