Beispiel #1
0
        public List <Flow> GetFlows()
        {
            var url = $"{Constants.ApiUrl}{"flows"}";

            var responseText = Internet.Get(url, _apiKey);

            return(JsonConvert.DeserializeObject <List <Flow> >(responseText));
        }
Beispiel #2
0
        private void EnsureConversationVisibility(string userId)
        {
            try
            {
                var url = $"{Constants.ApiUrl}{"private/"}{userId}";

                Internet.Put(url, _apiKey, "{ \"open\": true }");
            }
            catch
            {
                // Probably failed to create a conversation with itself - surprise!
            }
        }
Beispiel #3
0
        public void SendReminder(Reminder reminder)
        {
            EnsureConversationVisibility(reminder.UserId);

            var url = $"{Constants.ApiUrl}{"private/"}{reminder.UserId}{"/messages"}";

            var message = $"{{ \"event\": \"message\", \"content\": \"Here you go: {reminder.Url}\" }}";

            var responseText = Internet.Post(url, _apiKey, message);

            var result = JsonConvert.DeserializeObject <MessageSearchResult>(responseText);

            if (result.Id != null)
            {
                _tagService.AddTag(reminder.Id, reminder.OriginalFlowName, Constants.RemindMeSent);
            }
        }
Beispiel #4
0
        public List <MessageSearchResult> Search(string searchtext)
        {
            var result = new List <MessageSearchResult>();

            foreach (var flow in Flows)
            {
                var url = $"{Constants.ApiUrl}{"flows/"}{Constants.CompanyName}{"/"}{flow.ParameterizedName}{"/messages/?event=message&search="}{searchtext}";

                var responseText = Internet.Get(url, _apiKey);

                var searchResults = JsonConvert.DeserializeObject <List <MessageSearchResult> >(responseText)
                                    .Select(r => {
                    r.OriginalFlowName = flow.ParameterizedName;
                    r.FlowName         = flow.Name;
                    r.UserName         = Users.FirstOrDefault(u => u.Id == r.UserId)?.Name;
                    return(r);
                });

                result.AddRange(searchResults);
            }

            return(result);
        }
Beispiel #5
0
        public void AddTag(string messageId, string flowName, string message)
        {
            var url = $"{Constants.ApiUrl}{"flows/"}{Constants.CompanyName}{"/"}{flowName}{"/messages/"}{messageId}";

            Internet.Put(url, _apiKey, "{ \"tags\":  [\"" + message + "\"] }");
        }