コード例 #1
0
            public async Task <Models.API.v5.Clips.TopClipsResponse> GetTopClipsAsync(string channel = null, string cursor = null, string game = null, long limit = 10, Models.API.v5.Clips.Period period = Models.API.v5.Clips.Period.Week, bool trending = false)
            {
                List <KeyValuePair <string, string> > getParams = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("limit", limit.ToString())
                };
                string paramsStr = $"?limit={limit}";

                if (channel != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("channel", channel));
                }
                if (cursor != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("cursor", cursor));
                }
                if (game != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("game", game));
                }
                if (trending)
                {
                    getParams.Add(new KeyValuePair <string, string>("trending", "true"));
                }
                else
                {
                    getParams.Add(new KeyValuePair <string, string>("trending", "false"));
                }
                switch (period)
                {
                case Models.API.v5.Clips.Period.All:
                    getParams.Add(new KeyValuePair <string, string>("period", "all"));
                    break;

                case Models.API.v5.Clips.Period.Month:
                    getParams.Add(new KeyValuePair <string, string>("period", "month"));
                    break;

                case Models.API.v5.Clips.Period.Week:
                    getParams.Add(new KeyValuePair <string, string>("period", "week"));
                    break;

                case Models.API.v5.Clips.Period.Day:
                    getParams.Add(new KeyValuePair <string, string>("period", "day"));
                    break;
                }

                return(await Api.GetGenericAsync <Models.API.v5.Clips.TopClipsResponse>($"https://api.twitch.tv/kraken/clips/top", getParams, null).ConfigureAwait(false));
            }
コード例 #2
0
ファイル: Clips.cs プロジェクト: ermantepe/TwitchLib
            public async Task <Models.API.v5.Clips.TopClipsResponse> GetTopClipsAsync(string channel = null, string cursor = null, string game = null, long limit = 10, Models.API.v5.Clips.Period period = Models.API.v5.Clips.Period.Week, bool trending = false)
            {
                var getParams = new List <KeyValuePair <string, string> > {
                    new KeyValuePair <string, string>("limit", limit.ToString())
                };

                if (channel != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("channel", channel));
                }
                if (cursor != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("cursor", cursor));
                }
                if (game != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("game", game));
                }
                getParams.Add(trending
                    ? new KeyValuePair <string, string>("trending", "true")
                    : new KeyValuePair <string, string>("trending", "false"));
                switch (period)
                {
                case Models.API.v5.Clips.Period.All:
                    getParams.Add(new KeyValuePair <string, string>("period", "all"));
                    break;

                case Models.API.v5.Clips.Period.Month:
                    getParams.Add(new KeyValuePair <string, string>("period", "month"));
                    break;

                case Models.API.v5.Clips.Period.Week:
                    getParams.Add(new KeyValuePair <string, string>("period", "week"));
                    break;

                case Models.API.v5.Clips.Period.Day:
                    getParams.Add(new KeyValuePair <string, string>("period", "day"));
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(period), period, null);
                }

                return(await Api.GetGenericAsync <Models.API.v5.Clips.TopClipsResponse>("https://api.twitch.tv/kraken/clips/top", getParams).ConfigureAwait(false));
            }