Пример #1
0
        public async Task <List <Models.Fail> > GetFailsAsync(int page = 0, Timeframe timeframe = Timeframe.TODAY, Order order = Order.HOT, bool nsfw = true, string game = null, string streamer = null)
        {
            var endpoint = $"{LIVESTREAMFAILS_BASE_URL}/load/loadPosts.php";

            var mode       = getPostMode(game, streamer);
            var parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(QUERY_MODE, mode.ToDescriptionString()),
                new KeyValuePair <string, string>(QUERY_PAGE, page.ToString()),
                new KeyValuePair <string, string>(QUERY_TIMEFRAME, timeframe.ToDescriptionString()),
                new KeyValuePair <string, string>(QUERY_ORDER, order.ToDescriptionString()),
                new KeyValuePair <string, string>(QUERY_NSFW, nsfw ? "1" : "0")
            };

            switch (mode)
            {
            case Mode.STREAMER:
                parameters.Add(new KeyValuePair <string, string>(QUERY_MODE_STREAMER, streamer));
                break;

            case Mode.GAME:
                parameters.Add(new KeyValuePair <string, string>(QUERY_MODE_GAME, game));
                break;

            case Mode.STANDARD:
                // do nothing
                break;

            default:
                throw new Exception($"Unknown mode: {mode.ToString()} ({mode.ToDescriptionString()})");
            }

            var response = await Helpers.Http.GetRequestAsync(endpoint, parameters);

            return(Helpers.Parsing.ParseFails(response));
        }