pub struct LeagueClient { /* private fields */ }
Expand description
Main type for calling League API Endpoints.
Instances of LeagueClient
can be created using new
with a Region
parameter
LeagueClient
can have an embedded DDragonClient
instance embedded in itself,
reference to which can be obtained using ddragon
. NOTE: this method will panic if
you don’t create the instance using with_ddragon
.
Implementations§
Source§impl LeagueClient
impl LeagueClient
Sourcepub fn new(region: Region) -> Result<LeagueClient, ClientError>
pub fn new(region: Region) -> Result<LeagueClient, ClientError>
Constructor function for LeagueAPI struct, accepts type as a parameter
§Panics
This will panic if you do not provide the RIOT_API_KEY environment variable with value being api token.
Sourcepub async fn with_ddragon(self, language: LanguageCode) -> Self
pub async fn with_ddragon(self, language: LanguageCode) -> Self
Adds an embedded ddragon client instance to league api client that shares cache and client with parent.
Sourcepub fn ddragon(&mut self) -> &mut DDragonClient
pub fn ddragon(&mut self) -> &mut DDragonClient
Gets mutable (because of cache) reference to ddragon client embedded in lapi client.
§Panics
Do not call ddragon
if with_ddragon
is not called beforehand.
Sourcepub async fn get_summoner_by_name(
&self,
name: &str,
) -> Result<Summoner, ClientError>
pub async fn get_summoner_by_name( &self, name: &str, ) -> Result<Summoner, ClientError>
Get summoner by plaintext name
§Example
use narwhalol::{LeagueClient, Region, dto::api::Summoner, error::ClientError};
fn main() -> Result<(), ClientError> {
smol::run(async {
let mut lapi = LeagueClient::new(Region::RU).unwrap();
let summoner = lapi.get_summoner_by_name("Vetro").await?;
assert_eq!(summoner.name, "Vetro");
Ok(())
})
}