Struct LeagueClient

Source
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

Source

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.

Source

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.

Source

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.

Source

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(())
    })
}
Source

pub async fn get_champion_info(&mut self) -> Result<ChampionInfo, ClientError>

Source

pub async fn get_champion_masteries( &mut self, summoner_id: &str, ) -> Result<Vec<ChampionMastery>, ClientError>

Source

pub async fn get_champion_mastery_by_id( &mut self, summoner_id: &str, champion_id: u64, ) -> Result<ChampionMastery, ClientError>

Source

pub async fn get_total_mastery_score( &mut self, summoner_id: &str, ) -> Result<i32, ClientError>

Source

pub async fn get_league_exp_entries( &mut self, queue: RankedQueue, tier: RankedTier, division: Division, pages: Option<i32>, ) -> Result<Vec<LeagueInfo>, ClientError>

Trait Implementations§

Source§

impl Debug for LeagueClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LeagueClient

Source§

fn default() -> LeagueClient

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,