internal async Task <CollectionsResult> QueryAsync(String accessToken, Int32 questionId, Int32 offset, Int32 limit, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("collections/{0}/collections_v2?offset={1}&limit={2}", questionId, offset, limit, autoCache), accessToken); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Collections>(json); return(new CollectionsResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new CollectionsResult(new Exception(json))); } }
internal async Task <FavoriteResult> CheckFavoriteAsync(String access, Int32 answerId, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format("answers/{0}/is_favorited", answerId), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Favorite>(json); return(new FavoriteResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new FavoriteResult(new Exception(json))); } }
internal async Task <CollectionsResult> GetAnswerCollectionsAsync(String access, Int32 answerId, Int32 limit, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("answers/{0}/collections_v2?limit={1}", answerId, limit), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Collections>(json); return(new CollectionsResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new CollectionsResult(new Exception(json))); } }
internal async Task <PeopleFollowingResult> IsPeopleFollowingAsync(String accessToken, String userId, Int32 offset, Int32 limit, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format("people/{0}/is_following", userId), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <PeopleFollowing>(json); return(new PeopleFollowingResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new PeopleFollowingResult(new Exception(json))); } }
internal async Task <FollowingResult> CheckFollowingAsync(String access, String columnId, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("columns/{0}/is_following", columnId), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Following>(json); return(new FollowingResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new FollowingResult(new Exception(json))); } }
internal async Task <CommentsResult> GetCommentsAsync(String accessToken, Int32 articleId, String request, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format(request, articleId), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Comments>(json); return(new CommentsResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new CommentsResult(new Exception(json))); } }
internal async Task <QuestionsResult> SearchAsync(String accessToken, String keyword, Int32 offset, Int32 limit, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("search?q={0}&t=question&offset={1}&limit={2}", keyword, offset, limit), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Questions>(json); return(new QuestionsResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new QuestionsResult(new Exception(json))); } }
internal async Task <QuesRelaResult> GetRelationshipAsync(String accessToken, Int32 questionId, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("questions/{0}/relationship", questionId), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <QuesRelationShip>(json); return(new QuesRelaResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new QuesRelaResult(new Exception(json))); } }
public async Task <TopicResult> GetDetailAsync(String accessToken, Int32 topicId, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("topics/{0}", topicId), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Topic>(json); return(new TopicResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new TopicResult(new Exception(json))); } }
internal async Task <ProfileResult> GetProfileAsync(String accessToken, String userId = "", Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format("people/{0}", String.IsNullOrEmpty(userId) ? "self" : userId), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var userInfo = JsonConvert.DeserializeObject <Profile>(json); return(new ProfileResult(userInfo)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new ProfileResult(new Exception(json))); } }
internal async Task <TopicActivitiesResult> GetActivitiesAsync(String access, String request, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, request, access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <TopicActivities>(json); return(new TopicActivitiesResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new TopicActivitiesResult(new Exception(json))); } }
internal async Task <MessagesResult> GetMessages(String access, String request, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, request, access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; var obj = JsonConvert.DeserializeObject <Messages>(json); if (obj != null && obj.Items != null) { obj.Items = obj.Items.Reverse().ToArray(); } return(new MessagesResult(obj)); } else { var json = response.Error; return(new MessagesResult(new Exception(json))); } }
internal async Task <AnswersResult> GetAnswersAsync(String access, String request, String orderby, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("{0}{1}order_by={2}", request, request.Contains("?") ? "&" : "?", orderby), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Answers>(json); return(new AnswersResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new AnswersResult(new Exception(json))); } }
internal async Task <TableResult> GetDetailAsync(String access, String tableId, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format("roundtables/{0}", tableId), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <RoundTable>(json); return(new TableResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new TableResult(new Exception(json))); } }
/// <summary> /// Posts a request to Vault. /// </summary> public async Task <VaultResponse <T> > GetAsync <T>(string url) { var response = await HttpUtility.GetAsync(this.VaultUrl + "/v1" + url, 5000, new KeyValuePair <string, string>("X-Vault-Token", this.Token) ); if (response.Success) { return(JsonConvert.DeserializeObject <VaultResponse <T> >(response.Value)); } return(null); }
/// <summary> /// Tracks an event. /// </summary> /// <param name="eventCategory">The event category.</param> /// <param name="eventName">The name of the event.</param> public override void Track(string eventCategory, string eventName) { try { // Get the fingerprint for this machine var uid = Service.Providers.Resolve <AddressProvider>().GetFingerprint(); var url = string.Format("{0}?uid={1}&ec={2}&en={3}", Endpoint, uid, eventCategory, eventName); // Fire and forget HttpUtility.GetAsync(url, 5000).Forget(); } catch { // Ignore if the tracking failed. } }
internal async Task <FeedsResult> GetFeedsAsync(String accessToken, String request, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, request, accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; var obj = JsonConvert.DeserializeObject <Feeds>(json); return(new FeedsResult(obj)); } else { var json = response.Error; return(new FeedsResult(new Exception(json))); } }
public async Task <UseTopStoryResult> CheckUseStory(String access, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, "settings/lab", access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; var jsonModel = JsonConvert.DeserializeObject <UseTopStory>(json); return(new UseTopStoryResult(jsonModel)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new UseTopStoryResult(new Exception(json))); } }
internal async Task <NotifiesResult> GetLikesAync(String access, String request, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, request, access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; var obj = JsonConvert.DeserializeObject <Notifies>(json); return(new NotifiesResult(obj)); } else { var json = response.Error; return(new NotifiesResult(new Exception(json))); } }
internal async Task <NotificationsResult> CheckNotificationsAsync(String accessToken, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, "notifications/count", accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <Notifications>(json); return(new NotificationsResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new NotificationsResult(new Exception(json))); } }
public async Task <ShareResult> GetQuestionShareTemplate(String access, Int32 questionId, Boolean autoCache = false) { var client = new HttpUtility(); var response = await client.GetAsync(Utility.Instance.BaseUri, String.Format("questions/{0}/share", questionId), access, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var obj = JsonConvert.DeserializeObject <ShareTemplates>(json); return(new ShareResult(obj)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new ShareResult(new Exception(json))); } }
internal async Task <ExplorePeopleResult> ExplorePeopleAsync(String accessToken, Boolean autoCache = false) { var http = new HttpUtility(); var response = await http.GetAsync(Utility.Instance.BaseUri, String.Format("explore/people?offset=0&limit=20"), accessToken, autoCache); if (false == String.IsNullOrEmpty(response.Json)) { var json = response.Json; //json = Regex.Unescape(json); var userInfo = JsonConvert.DeserializeObject <ExplorePeople>(json); return(new ExplorePeopleResult(userInfo)); } else { var json = response.Error; //json = Regex.Unescape(json); return(new ExplorePeopleResult(new Exception(json))); } }