Example #1
0
        public Topic GetTopic(int id)
        {
            string  response = this.GetRequest("/t/{0}.json", id);
            dynamic topic    = JsonConvert.DeserializeObject(response);

            return(Topic.CreateFromJson(topic));
        }
Example #2
0
        public IEnumerable <Topic> GetTopics(string filter = "latest")
        {
            var validFilters = new[] { "top", "starred", "unread", "new", "latest" };

            if (!validFilters.Contains(filter))
            {
                throw new ArgumentException("filter");
            }

            string  response = this.GetRequest("/{0}.json", filter);
            dynamic json     = JsonConvert.DeserializeObject(response);
            dynamic topics   = json.topic_list.topics;

            foreach (dynamic topic in topics)
            {
                yield return(Topic.CreateFromJson(topic));
            }
        }