Ejemplo n.º 1
0
        public async Task <ActionAlert> GetAsync(string id)
        {
            string _id = id;
            string uri = String.Format("{0}/{1}", _endpoint, _id);

            var message = await WebRequest(uri);

            string json = await message.Content.ReadAsStringAsync();

            JObject             httpResponse = JObject.Parse(json);
            IList <JToken>      data         = httpResponse["data"].Children().ToList();
            var                 alertsJson   = JsonConvert.SerializeObject(data);
            JArray              alertsArray  = JArray.Parse(alertsJson);
            IList <ActionAlert> alerts       = alertsArray.Select(e => new ActionAlert
            {
                Id               = (string)e["id"],
                Title            = (string)e["attributes"]["title"],
                Type             = (string)e["type"],
                Date             = (string)e["attributes"]["date"],
                ShortDescription = (string)e["attributes"]["short_description"],
                Body             = (string)e["attributes"]["body"],
                BodyHTML         = (string)e["attributes"]["body_HTML"],
                TargetUrl        = (string)e["attributes"]["target_url"],
                TweetId          = (string)e["attributes"]["tweet_id"],
                TwitterUrl       = (string)e["attributes"]["twitter_url"]
            }).ToList();
            ActionAlert alert = alerts.FirstOrDefault();

            return(alert);
        }
Ejemplo n.º 2
0
        public async Task <ActionAlert> GetActionAsync(string id)
        {
            var alert = new ActionAlert
            {
                Id               = "1",
                Title            = "Look, a tweet!",
                Date             = "March 23",
                ShortDescription = "Bleh",
                Body             = "Body"
            };

            return(alert);
        }