Ejemplo n.º 1
0
        public static IEnumerable <ConversationSummary> GetConversations()
        {
            string        Endpoint       = "/conversations";
            Uri           RequestAddress = new Uri(string.Format("{0}{1}", BASEURI, Endpoint));
            string        Response       = RestServices.GetResponse(RequestAddress, APIKEY);
            List <JToken> tokens         = new List <JToken>(JObject.Parse(Response).SelectTokens("results"));

            foreach (JToken t in tokens.Children())
            {
                yield return(ConversationSummary.DeserializeJSON(t));
            }
        }
Ejemplo n.º 2
0
        public static Conversation DeserializeJSON(JToken Token)
        {
            Conversation c = new Conversation()
            {
                Summary  = ConversationSummary.DeserializeJSON(Token.SelectToken("conversation").SelectToken("summary")),
                Messages = new List <Message>()
            };

            foreach (JToken t in Token.First.First.SelectToken("messages").Children())
            {
                c.Messages.Add(Message.DeserializeJSON(t));
            }
            return(c);
        }
Ejemplo n.º 3
0
        public static async Task <List <ConversationSummary> > GetConversationsAsync()
        {
            string Endpoint       = "/conversations";
            Uri    RequestAddress = new Uri(string.Format("{0}{1}", BASEURI, Endpoint));
            string Response       = await RestServices.GetResponseAsync(RequestAddress, APIKEY).ConfigureAwait(false);

            List <JToken> tokens         = new List <JToken>(JObject.Parse(Response).SelectTokens("results"));
            List <ConversationSummary> l = new List <ConversationSummary>();

            foreach (JToken t in tokens.Children())
            {
                l.Add(ConversationSummary.DeserializeJSON(t));
            }
            return(l);
        }