/// <summary> /// ステータスポストをFrostに投稿します。 /// </summary> /// <param name="text">投稿する本文</param> /// <returns></returns> public async Task <StatusPost> CreateStatusPost(string text) { var res = await _Request(HttpMethod.Post, "posts/post_status", new Dictionary <string, string> { ["text"] = text }); var dic = JsonConvert.DeserializeObject <Dictionary <string, JToken> >(res.ContentJson); return(StatusPost.FromJson(dic["postStatus"].ToString())); }
public async Task <List <IPost> > GetHomeTimeline(string userId, int?limit = null) { var parameters = new Dictionary <string, string>(); if (limit != null) { parameters.Add("limit", limit.ToString()); } var res = await _Request(HttpMethod.Get, $"users/{userId}/timelines/home", parameters); var dic = JsonConvert.DeserializeObject <Dictionary <string, JToken> >(res.ContentJson); // TODO: エラー処理 return(dic["posts"].Select((postJToken) => { var post = postJToken.ToObject <Dictionary <string, JToken> >(); var postType = post["type"].ToString(); IPost result; if (postType == "status") { result = StatusPost.FromJson(postJToken.ToString()); } else if (postType == "article") { throw new NotSupportedException("article post は未サポートです。"); } else if (postType == "reference") { throw new NotSupportedException("reference post は未サポートです。"); } else { throw new Exception("不明なタイプのポストが含まれています。"); } return result; }).ToList()); }