pub async fn get_rank_info(
client: &Client,
region_str: &str,
summoner_id: &str,
riot_api_key: &str,
) -> Result<Vec<HashMap<String, Value>>, Box<dyn Error + Send + Sync>>Expand description
⚙️ Function: Fetches ranked information for a player using their summoner ID.
This function sends a request to the Riot API to retrieve ranked information for a player, including their rank, division, league points (LP), wins, and losses in different game modes (e.g., Solo/Duo, Flex).
§Parameters:
client: An instance of thereqwest::Clientused to send HTTP requests.region_str: A string representing the region (e.g.,euw1,na1,kr) where the player’s account is located.summoner_id: The unique summoner ID of the player, used to identify them in the ranked ladder.riot_api_key: The API key used to authenticate the request with the Riot API.
§Returns:
Result<Vec<HashMap<String, Value>>, Error>: A vector ofHashMapobjects containing ranked information for each game mode (Solo/Duo, Flex) or an error if the request fails.
§⚠️ Notes:
- The returned ranked information includes game modes like Solo/Duo and Flex, along with details such as tier, rank, LP, wins, and losses.
- The function returns an empty vector if no ranked data is found for the player in the specified region.
§Example:
let rank_info = get_rank_info(&client, "euw1", "abcdef1234567890abcdef1234567890", riot_api_key).await?;The resulting rank_info will contain ranked data for different game modes, such as:
[
{
"queueType": "RANKED_SOLO_5x5",
"tier": "Gold",
"rank": "IV",
"leaguePoints": 50,
"wins": 30,
"losses": 20
},
{
"queueType": "RANKED_FLEX_SR",
"tier": "Silver",
"rank": "II",
"leaguePoints": 75,
"wins": 15,
"losses": 10
}
]