Ejemplo n.º 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);
        }
Ejemplo n.º 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 }
         })
     );
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public void SetCategoryTopic(Topic topic, Category category)
 {
     this.SetTopicsCategoryBulk(new[] { topic }, category);
 }
Ejemplo n.º 5
0
 public Topic CreateTopic(Category category, string title, string body)
 {
     return Topic.Null;
 }
Ejemplo n.º 6
0
 public IEnumerable<Topic> GetTopicsByCategory(Category category, string filter = "latest")
 {
     return Enumerable.Empty<Topic>();
 }
Ejemplo n.º 7
0
 public void SetTopicsCategoryBulk(IEnumerable<Topic> topics, Category category)
 {
 }
Ejemplo n.º 8
0
 public void SetCategoryTopic(Topic topic, Category category)
 {
 }