use crate::error::Error;
use crate::http::Client;
use crate::types::*;
pub struct Player<'a> {
player_id: String,
client: &'a Client,
}
impl<'a> Player<'a> {
pub fn new(player_id: impl Into<String>, client: &'a Client) -> Self {
Self {
player_id: player_id.into(),
client,
}
}
pub fn id(&self) -> &str {
&self.player_id
}
pub async fn get(&self) -> Result<crate::types::Player, Error> {
self.client.get_player(&self.player_id).await
}
pub async fn stats(&self, game_id: &str) -> Result<PlayerStats, Error> {
self.client.get_player_stats(&self.player_id, game_id).await
}
pub async fn history(
&self,
game: &str,
from: Option<i64>,
to: Option<i64>,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<MatchHistoryList, Error> {
self.client
.get_player_history(&self.player_id, game, from, to, offset, limit)
.await
}
pub async fn bans(
&self,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<PlayerBansList, Error> {
self.client
.get_player_bans(&self.player_id, offset, limit)
.await
}
pub async fn hubs(&self, offset: Option<i64>, limit: Option<i64>) -> Result<HubsList, Error> {
self.client
.get_player_hubs(&self.player_id, offset, limit)
.await
}
pub async fn teams(&self, offset: Option<i64>, limit: Option<i64>) -> Result<TeamList, Error> {
self.client
.get_player_teams(&self.player_id, offset, limit)
.await
}
pub async fn tournaments(
&self,
offset: Option<i64>,
limit: Option<i64>,
) -> Result<TournamentsList, Error> {
self.client
.get_player_tournaments(&self.player_id, offset, limit)
.await
}
}