Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /// <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());
 }
Ejemplo n.º 5
0
 /// <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());
 }
Ejemplo n.º 6
0
        /// <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());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a collection of past races synchronously
        /// </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 ReadOnlyCollection <PastRace> Get(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(SrlClient.Get <PastRacesCollection>($"{BasePath}?page={page}&pageSize={pageSize}{playerFilter}{gameFilter}")?.Races?.AsReadOnly());
        }
Ejemplo n.º 8
0
 /// <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();
Ejemplo n.º 9
0
 /// <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()}");
Ejemplo n.º 10
0
 /// <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();
Ejemplo n.º 11
0
 /// <summary>
 /// Gets the monthly statistics synchronously
 /// </summary>
 /// <returns>Returns SRLs monthly stats</returns>
 public ReadOnlyCollection <SRLStats> GetMonthlySRLStats()
 => SrlClient.Get <MonthlyStats>($"{BasePath}/monthly")?.Stats?.AsReadOnly();
Ejemplo n.º 12
0
 /// <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()}");
Ejemplo n.º 13
0
 /// <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();
Ejemplo n.º 14
0
 /// <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()}");
Ejemplo n.º 15
0
 /// <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()}");