Function get_latest_match_id

Source
async fn get_latest_match_id(
    client: &Client,
    puuid: &str,
    riot_api_key: &str,
) -> Result<String, Box<dyn Error + Send + Sync>>
Expand description

⚙️ Function: Fetches the latest match ID for a given summoner using their PUUID.

This asynchronous function retrieves the most recent match ID for a summoner by making a request to the Riot API. It uses the summoner’s puuid to query their match history and returns the match ID of the most recent game.

§Parameters:

  • client: A reference to the reqwest::Client, used to make HTTP requests to the Riot API.
  • puuid: A string slice representing the summoner’s PUUID (a unique identifier for each player in Riot’s system).
  • riot_api_key: A string slice representing the Riot API key, used for authorized requests.

§Returns:

  • Result<String, Error>: Returns the latest match ID as a string if successful, or an error if the request or retrieval fails.

§Example:

This function is typically used to get the latest match ID for a summoner in order to check for new matches:

let latest_match_id = get_latest_match_id(&client, puuid, riot_api_key).await?;

§Notes:

  • The function calls get_matchs_id to retrieve the match history and then returns the first match in the list, which corresponds to the most recent match.
  • The get_matchs_id function is expected to return a vector of match IDs, from which the latest match (the first one) is extracted and returned.