コード例 #1
0
ファイル: StatsClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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);
 }
コード例 #2
0
ファイル: StatsClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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);
 }
コード例 #3
0
ファイル: GamesClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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);
 }
コード例 #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());
 }
コード例 #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());
 }
コード例 #6
0
ファイル: GamesClient.cs プロジェクト: BitPatty/SRLApiClient
        /// <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());
        }
コード例 #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());
        }
コード例 #8
0
ファイル: RacesClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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();
コード例 #9
0
ファイル: RacesClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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()}");
コード例 #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();
コード例 #11
0
ファイル: StatsClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <summary>
 /// Gets the monthly statistics synchronously
 /// </summary>
 /// <returns>Returns SRLs monthly stats</returns>
 public ReadOnlyCollection <SRLStats> GetMonthlySRLStats()
 => SrlClient.Get <MonthlyStats>($"{BasePath}/monthly")?.Stats?.AsReadOnly();
コード例 #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()}");
コード例 #13
0
ファイル: GamesClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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();
コード例 #14
0
ファイル: GamesClient.cs プロジェクト: BitPatty/SRLApiClient
 /// <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()}");
コード例 #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()}");