Example #1
0
        public IEnumerable<Topic> GetTopicsByCategory(Category category, string filter = "latest")
        {
            var validFilters = new[] { "top", "starred", "unread", "new", "latest" };
            if (!validFilters.Contains(filter))
                throw new ArgumentException("filter");

            string response = this.GetRequest("/c/{0}/l/{1}.json", category.UrlFormatted, filter);
            dynamic json = JsonConvert.DeserializeObject(response);
            dynamic topics = json.topic_list.topics;
            foreach (dynamic topic in topics)
                yield return Topic.CreateFromJson(topic);
        }
Example #2
0
 public void SetTopicsCategoryBulk(IEnumerable<Topic> topics, Category category)
 {
     this.PutRequest(
         "/topics/bulk",
         topics.Select(t => new KeyValuePair<string, string>("topic_ids[]", t.Id.ToString()))
         .Concat(new Dictionary<string, string>()
         {
             { "operation[type]", "change_category" },
             { "operation[category_name]", category.Name }
         })
     );
 }
Example #3
0
        public Topic CreateTopic(Category category, string title, string body)
        {
            string response = this.PostRequest(
                "/posts",
                new Dictionary<string, string> 
                { 
                    { "category", category.Name },
                    { "title", title },
                    { "raw", body }
                }
            );

            dynamic topic = JsonConvert.DeserializeObject(response);
            return Topic.CreateFromPostJson(topic, title);
        }
Example #4
0
 public void SetCategoryTopic(Topic topic, Category category)
 {
     this.SetTopicsCategoryBulk(new[] { topic }, category);
 }
Example #5
0
 public Topic CreateTopic(Category category, string title, string body)
 {
     return Topic.Null;
 }
Example #6
0
 public IEnumerable<Topic> GetTopicsByCategory(Category category, string filter = "latest")
 {
     return Enumerable.Empty<Topic>();
 }
Example #7
0
 public void SetTopicsCategoryBulk(IEnumerable<Topic> topics, Category category)
 {
 }
Example #8
0
 public void SetCategoryTopic(Topic topic, Category category)
 {
 }