コード例 #1
0
        public IEnumerable <Game> GetGames(
            string name           = null,
            int?yearOfRelease     = null,
            string platformId     = null,
            string regionId       = null,
            string moderatorId    = null,
            int?elementsPerPage   = null,
            GameEmbeds embeds     = default,
            GamesOrdering orderBy = default)
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

            if (!string.IsNullOrEmpty(name))
            {
                parameters.Add(string.Format("name={0}", Uri.EscapeDataString(name)));
            }

            if (yearOfRelease.HasValue)
            {
                parameters.Add(string.Format("released={0}", yearOfRelease.Value));
            }

            if (!string.IsNullOrEmpty(platformId))
            {
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            }

            if (!string.IsNullOrEmpty(regionId))
            {
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            }

            if (!string.IsNullOrEmpty(moderatorId))
            {
                parameters.Add(string.Format("moderator={0}", Uri.EscapeDataString(moderatorId)));
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetGamesUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri, x => Game.Parse(baseClient, x) as Game));
        }
コード例 #2
0
ファイル: UsersClient.cs プロジェクト: mysidia/LiveSplit-Sid
        public IEnumerable <User> GetUsers(
            string name           = null,
            string twitch         = null, string hitbox        = null,
            string twitter        = null, string speedrunslive = null,
            int?elementsPerPage   = null,
            UsersOrdering orderBy = default(UsersOrdering))
        {
            var parameters = new List <string>();

            if (!string.IsNullOrEmpty(name))
            {
                parameters.Add(string.Format("name={0}",
                                             Uri.EscapeDataString(name)));
            }

            if (!string.IsNullOrEmpty(twitch))
            {
                parameters.Add(string.Format("twitch={0}",
                                             Uri.EscapeDataString(twitch)));
            }

            if (!string.IsNullOrEmpty(hitbox))
            {
                parameters.Add(string.Format("hitbox={0}",
                                             Uri.EscapeDataString(hitbox)));
            }

            if (!string.IsNullOrEmpty(twitter))
            {
                parameters.Add(string.Format("twitter={0}",
                                             Uri.EscapeDataString(twitter)));
            }

            if (!string.IsNullOrEmpty(speedrunslive))
            {
                parameters.Add(string.Format("speedrunslive={0}",
                                             Uri.EscapeDataString(speedrunslive)));
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage));
            }

            parameters.AddRange(orderBy.ToParameters());

            var uri = GetUsersUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri,
                                                 x => User.Parse(baseClient, x) as User));
        }
コード例 #3
0
ファイル: LevelsClient.cs プロジェクト: mysidia/LiveSplit-Sid
        public IEnumerable <Leaderboard> GetRecords(string levelId,
                                                    int?top                  = null, bool skipEmptyLeaderboards = false,
                                                    int?elementsPerPage      = null,
                                                    LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (top.HasValue)
            {
                parameters.Add(string.Format("top={0}", top.Value));
            }
            if (skipEmptyLeaderboards)
            {
                parameters.Add("skip-empty=true");
            }
            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetLevelsUri(string.Format("/{0}/records{1}",
                                                 Uri.EscapeDataString(levelId),
                                                 parameters.ToParameters()));

            return(baseClient.DoPaginatedRequest <Leaderboard>(uri,
                                                               x => Leaderboard.Parse(baseClient, x)));
        }
コード例 #4
0
ファイル: SeriesClient.cs プロジェクト: mysidia/LiveSplit-Sid
        public IEnumerable <Series> GetMultipleSeries(
            string name            = null, string abbreviation = null,
            string moderatorId     = null, int?elementsPerPage = null,
            SeriesEmbeds embeds    = default(SeriesEmbeds),
            SeriesOrdering orderBy = default(SeriesOrdering))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

            if (!string.IsNullOrEmpty(name))
            {
                parameters.Add(string.Format("name={0}", Uri.EscapeDataString(name)));
            }

            if (!string.IsNullOrEmpty(abbreviation))
            {
                parameters.Add(string.Format("abbreviation={0}", Uri.EscapeDataString(abbreviation)));
            }

            if (!string.IsNullOrEmpty(moderatorId))
            {
                parameters.Add(string.Format("moderator={0}", Uri.EscapeDataString(moderatorId)));
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetSeriesUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri,
                                                 x => Series.Parse(baseClient, x) as Series));
        }
コード例 #5
0
        public IEnumerable <Platform> GetPlatforms(int?elementsPerPage       = null,
                                                   PlatformsOrdering orderBy = default(PlatformsOrdering))
        {
            var parameters = new List <string>();

            parameters.AddRange(orderBy.ToParameters());

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetPlatformsUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri,
                                                 x => Platform.Parse(baseClient, x) as Platform));
        }
コード例 #6
0
        public IEnumerable <Notification> GetNotifications(
            int?elementsPerPage            = null,
            NotificationsOrdering ordering = default(NotificationsOrdering))
        {
            var parameters = new List <string>();

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            parameters.AddRange(ordering.ToParameters());

            var uri = GetNotificationsUri(string.Format("{0}",
                                                        parameters.ToParameters()));

            return(baseClient.DoPaginatedRequest <Notification>(uri,
                                                                x => Notification.Parse(baseClient, x)));
        }
コード例 #7
0
        public IEnumerable <Run> GetRuns(
            string userId         = null, string guestName      = null,
            string examerUserId   = null, string gameId         = null,
            string levelId        = null, string categoryId     = null,
            string platformId     = null, string regionId       = null,
            bool onlyEmulatedRuns = false, RunStatusType?status = null,
            int?elementsPerPage   = null,
            RunEmbeds embeds      = default,
            RunsOrdering orderBy  = default)
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (!string.IsNullOrEmpty(userId))
            {
                parameters.Add(string.Format("user={0}", Uri.EscapeDataString(userId)));
            }

            if (!string.IsNullOrEmpty(guestName))
            {
                parameters.Add(string.Format("guest={0}", Uri.EscapeDataString(guestName)));
            }

            if (!string.IsNullOrEmpty(examerUserId))
            {
                parameters.Add(string.Format("examiner={0}", Uri.EscapeDataString(examerUserId)));
            }

            if (!string.IsNullOrEmpty(gameId))
            {
                parameters.Add(string.Format("game={0}", Uri.EscapeDataString(gameId)));
            }

            if (!string.IsNullOrEmpty(levelId))
            {
                parameters.Add(string.Format("level={0}", Uri.EscapeDataString(levelId)));
            }

            if (!string.IsNullOrEmpty(categoryId))
            {
                parameters.Add(string.Format("category={0}", Uri.EscapeDataString(categoryId)));
            }

            if (!string.IsNullOrEmpty(platformId))
            {
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            }

            if (!string.IsNullOrEmpty(regionId))
            {
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            }

            if (onlyEmulatedRuns)
            {
                parameters.Add("emulated=yes");
            }

            if (status.HasValue)
            {
                switch (status.Value)
                {
                case RunStatusType.New:
                    parameters.Add("status=new"); break;

                case RunStatusType.Rejected:
                    parameters.Add("status=rejected"); break;

                case RunStatusType.Verified:
                    parameters.Add("status=verified"); break;
                }
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage));
            }

            parameters.AddRange(orderBy.ToParameters());

            var uri = GetRunsUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri, x => Run.Parse(baseClient, x) as Run));
        }