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