/// <summary> /// Gets the rules for a game asynchronously /// </summary> /// <param name="gameAbbreviation">The games abbreviation</param> /// <returns>Returns the rules string</returns> public async Task <string> GetRulesAsync(string gameAbbreviation) { if (string.IsNullOrWhiteSpace(gameAbbreviation)) { throw new ArgumentException(nameof(gameAbbreviation), "Parameter can't be empty"); } return((await SrlClient.GetAsync <GameRules>($"/rules/{gameAbbreviation}").ConfigureAwait(false))?.Rules); }
/// <summary> /// Gets a single past race synchronously /// </summary> /// <param name="raceId">The races id</param> /// <returns>Returns the past race</returns> public PastRace Get(string raceId) { if (string.IsNullOrWhiteSpace(raceId)) { throw new ArgumentException(nameof(raceId), "Parameter can't be empty"); } return(SrlClient.Get <PastRacesCollection>($"{BasePath}/{raceId.ToLower()}")?.Races?.FirstOrDefault()); }
/// <summary> /// Gets the rules for a game synchronously /// </summary> /// <param name="gameAbbreviation">The games abbreviation</param> /// <returns>Returns the rules string</returns> public string GetRules(string gameAbbreviation) { if (string.IsNullOrWhiteSpace(gameAbbreviation)) { throw new ArgumentException(nameof(gameAbbreviation), "Parameter can't be empty"); } return(SrlClient.Get <GameRules>($"/rules/{gameAbbreviation}")?.Rules); }
/// <summary> /// Gets a single past race asynchronously /// </summary> /// <param name="raceId">The races id</param> /// <returns>Returns the past race</returns> public async Task <PastRace> GetAsync(string raceId) { if (string.IsNullOrWhiteSpace(raceId)) { throw new ArgumentException(nameof(raceId), "Parameter can't be empty"); } return((await SrlClient.GetAsync <PastRacesCollection>($"{BasePath}/{raceId.ToLower()}").ConfigureAwait(false))?.Races?.FirstOrDefault()); }
/// <summary> /// Gets the statistics for a single game asynchronously /// </summary> /// <param name="gameAbbreviation">The games abbreviation</param> /// <returns>Returns the games stats</returns> public async Task <GameStats> GetGameStatsAsync(string gameAbbreviation) { if (string.IsNullOrWhiteSpace(gameAbbreviation)) { throw new ArgumentException(nameof(gameAbbreviation), "Parameter can't be empty"); } return((await SrlClient.GetAsync <GameEndpoint>($"{BasePath}?game={gameAbbreviation}").ConfigureAwait(false))?.Stats); }
/// <summary> /// Gets the statistics for a player synchronously /// </summary> /// <param name="playerName">The players name</param> /// <returns>Returns the players stats</returns> public PlayerStats GetPlayerStats(string playerName) { if (string.IsNullOrWhiteSpace(playerName)) { throw new ArgumentException(nameof(playerName), "Parameter can't be empty"); } return(SrlClient.Get <PlayerEndpoint>($"{BasePath}?player={playerName}")?.Stats); }
/// <summary> /// Searches a player asynchronously /// </summary> /// <param name="name">The players name</param> /// <returns>List of players matching the queried name</returns> public async Task <ReadOnlyCollection <Player> > SearchAsync(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException(nameof(name), "Parameter can't be empty"); } return((await SrlClient.GetAsync <PlayerSearch>($"{BasePath}?search={name.ToLower()}").ConfigureAwait(false))?.Players?.AsReadOnly()); }
/// <summary> /// Searches a player synchronously /// </summary> /// <param name="name">The players name</param> /// <returns>List of players matching the queried name</returns> public ReadOnlyCollection <Player> Search(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException(nameof(name), "Parameter can't be empty"); } return(SrlClient.Get <PlayerSearch>($"{BasePath}?search={name.ToLower()}")?.Players?.AsReadOnly()); }
/// <summary> /// Gets the statistics for a single game synchronously /// </summary> /// <param name="gameAbbreviation">The games abbreviation</param> /// <returns>Returns the games stats</returns> public GameStats GetGameStats(string gameAbbreviation) { if (string.IsNullOrWhiteSpace(gameAbbreviation)) { throw new ArgumentException(nameof(gameAbbreviation), "Parameter can't be empty"); } return(SrlClient.Get <GameEndpoint>($"{BasePath}?game={gameAbbreviation}")?.Stats); }
/// <summary> /// Gets the statistics for a player asynchronously /// </summary> /// <param name="playerName">The players name</param> /// <returns>Returns the players stats</returns> public async Task <PlayerStats> GetPlayerStatsAsync(string playerName) { if (string.IsNullOrWhiteSpace(playerName)) { throw new ArgumentException(nameof(playerName), "Parameter can't be empty"); } return((await SrlClient.GetAsync <PlayerEndpoint>($"{BasePath}?player={playerName}").ConfigureAwait(false))?.Stats); }
/// <summary> /// Searches for a game synchronously /// </summary> /// <param name="name">The games name or abbreviation to search for</param> /// <returns>Returns a list of games matching the search query</returns> public ReadOnlyCollection <Game> Search(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException(nameof(name), "Parameter can't be empty"); } GameCollection gs = SrlClient.Get <GameCollection>($"{BasePath}?search={name.ToLower()}"); return(gs?.Games?.AsReadOnly()); }
/// <summary> /// Gets a collection of past races asynchronously /// </summary> /// <param name="playerName">The players name</param> /// <param name="gameAbbreviation">The games abbreviation</param> /// <param name="page">The page number</param> /// <param name="pageSize">The page size</param> /// <returns>Returns the race collection</returns> public async Task <ReadOnlyCollection <PastRace> > GetAsync(string playerName = null, string gameAbbreviation = null, int page = 1, int pageSize = 20) { if (page < 1) { throw new ArgumentException(nameof(page), "Parameter must be 1 or greater"); } if (pageSize < 1) { throw new ArgumentException(nameof(pageSize), "Parameter must be 1 or greater"); } string playerFilter = !string.IsNullOrWhiteSpace(playerName) ? $"&player={playerName}" : ""; string gameFilter = !string.IsNullOrWhiteSpace(gameAbbreviation) ? $"&game={gameAbbreviation}" : ""; return((await SrlClient.GetAsync <PastRacesCollection>($"{BasePath}?page={page}&pageSize={pageSize}{playerFilter}{gameFilter}").ConfigureAwait(false))?.Races?.AsReadOnly()); }
/// <summary> /// Edits a players profile /// </summary> /// <permission cref="UserRole.User">Editing a profile requires the <see cref="SRLClient"/> to be authorized /// with the appropriate account (or the racebot account)</permission> /// <param name="playerName">The players name</param> /// <param name="youtube">The new youtube channel</param> /// <param name="twitter">The new twitter name</param> /// <param name="channel">The new streaming channel</param> /// <param name="api">The new Streaming API</param> /// <param name="country">The new Country</param> /// <param name="casename">The new name capitalization</param> /// <returns>Returns true on success</returns> public bool Edit(string playerName, string youtube = null, string twitter = null, string channel = null, StreamApi api = StreamApi.Unknown, string country = null, string casename = null) { Player p = Get(playerName); if (p != null && SrlClient.User.Role >= UserRole.User && (SrlClient.User.Name.Equals(playerName, StringComparison.OrdinalIgnoreCase) || SrlClient.User.Name.Equals("racebot", StringComparison.OrdinalIgnoreCase))) { Dictionary <string, string> dict = new Dictionary <string, string>(); if (youtube != null) { dict.Add("youtube", p.Youtube); } if (twitter != null) { dict.Add("twitter", p.Twitter); } if (channel != null) { dict.Add("channel", p.Channel); } if (api != StreamApi.Unknown) { dict.Add("api", api.ToString().ToLower()); } if (country != null) { dict.Add("country", p.Country); } if (casename?.Equals(playerName, StringComparison.OrdinalIgnoreCase) == true) { dict.Add("casename", casename); } if (dict.Count > 0 && SrlClient.Put(BasePath + "/" + playerName, dict)) { return(SrlClient.User.Verify()); } } return(false); }
/// <summary> /// Gets a game synchronously /// </summary> /// <param name="abbrev">The games abbreviation</param> /// <returns>Returns the game</returns> public Game Get(string abbrev) => SrlClient.Get <Game>($"{BasePath}/{abbrev.ToLower()}");
/// <summary> /// Gets the monthly statistics asynchronously /// </summary> /// <returns>Returns SRLs monthly stats</returns> public async Task <ReadOnlyCollection <SRLStats> > GetMonthlySRLStatsAsync() => (await SrlClient.GetAsync <MonthlyStats>($"{BasePath}/monthly").ConfigureAwait(false))?.Stats?.AsReadOnly();
/// <summary> /// Gets the monthly statistics synchronously /// </summary> /// <returns>Returns SRLs monthly stats</returns> public ReadOnlyCollection <SRLStats> GetMonthlySRLStats() => SrlClient.Get <MonthlyStats>($"{BasePath}/monthly")?.Stats?.AsReadOnly();
/// <summary> /// Gets the list of available countries synchronously /// </summary> /// <returns>Returns the list of countries</returns> public ReadOnlyCollection <string> Get() => SrlClient.Get <Countries>(BasePath).List.AsReadOnly();
/// <summary> /// Gets a single leaderboard asynchronously /// </summary> /// <param name="abbrev">The games abbreviation</param> /// <returns>Returns the leaderboard</returns> public async Task <Leaderboard> GetAsync(string abbrev) => await SrlClient.GetAsync <Leaderboard>($"{BasePath}/{abbrev.ToLower()}").ConfigureAwait(false);
/// <summary> /// Gets a single player asynchronously /// </summary> /// <param name="name">The players name</param> /// <returns>Returns the player</returns> public async Task <Player> GetAsync(string name) => await SrlClient.GetAsync <Player>($"{ BasePath}/{name.ToLower()}").ConfigureAwait(false);
/// <summary> /// Gets the currently active races synchronously /// </summary> /// <returns>Returns a list of active races</returns> public ReadOnlyCollection <Race> GetActive() => SrlClient.Get <ActiveRaces>(BasePath)?.Races?.AsReadOnly();
/// <summary> /// Gets a single race synchronously /// </summary> /// <param name="raceId">The races id</param> /// <returns>Returns the <see cref="Race"/></returns> public Race Get(string raceId) => SrlClient.Get <Race>($"{BasePath}/{raceId.ToLower()}");
/// <summary> /// Gets the list of available countries synchronously /// </summary> /// <returns>Returns the list of countries</returns> public async Task <ReadOnlyCollection <string> > GetAsync() => (await SrlClient.GetAsync <Countries>(BasePath).ConfigureAwait(false)).List.AsReadOnly();
/// <summary> /// Performs a bulk request on the games endpoint /// </summary> /// <returns>Returns the list of available games</returns> public ReadOnlyCollection <Game> GetAll() => SrlClient.Get <GameCollection>(BasePath)?.Games.AsReadOnly();
/// <summary> /// Gets a single race asynchronously /// </summary> /// <param name="raceId">The races id</param> /// <returns>Returns the <see cref="Race"/></returns> public async Task <Race> GetAsync(string raceId) => await SrlClient.GetAsync <Race>($"{BasePath}/{raceId.ToLower()}").ConfigureAwait(false);
/// <summary> /// Gets a single leaderboard synchronously /// </summary> /// <param name="abbrev">The games abbreviation</param> /// <returns>Returns the leaderboard</returns> public Leaderboard Get(string abbrev) => SrlClient.Get <Leaderboard>($"{BasePath}/{abbrev.ToLower()}");
/// <summary> /// Gets the currently active races asynchronously /// </summary> /// <returns>Returns a list of active races</returns> public async Task <ReadOnlyCollection <Race> > GetActiveAsync() => (await SrlClient.GetAsync <ActiveRaces>(BasePath).ConfigureAwait(false))?.Races?.AsReadOnly();
/// <summary> /// Gets a single player synchronously /// </summary> /// <param name="name">The players name</param> /// <returns>Returns the player</returns> public Player Get(string name) => SrlClient.Get <Player>($"{ BasePath}/{name.ToLower()}");