Esempio n. 1
0
 /// <summary>
 /// Unlikes message, asynchronously.
 /// </summary>
 /// <param name="messageId">The message identifier.</param>
 /// <returns>
 /// The completion task.
 /// </returns>
 public async Task UnLikeMessageAsync(int messageId)
 {
     using (HttpResponseMessage response = await this.Client.DeleteAsync(YammerService.BuildRequest("messages/liked_by/current.json", "message_id", messageId.ToString())))
     {
         response.EnsureSuccessStatusCode();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Likes the message, asynchronously.
 /// </summary>
 /// <param name="messageId">The message identifier.</param>
 /// <returns>
 /// The completion task.
 /// </returns>
 public async Task LikeMessageAsync(int messageId)
 {
     using (StringContent content = new StringContent(string.Empty))
         using (HttpResponseMessage response = await this.Client.PostAsync(YammerService.BuildRequest("messages/liked_by/current.json", "message_id", messageId.ToString()), content))
         {
             response.EnsureSuccessStatusCode();
         }
 }
Esempio n. 3
0
        /// <summary>
        /// Posts the message, asynchronously.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        /// The message feed task.
        /// </returns>
        public async Task <MessageFeed> PostMessageAsync(PostRequest request)
        {
            request.ThrowIfNull(nameof(request));

            User currentUser = await this.GetCurrentUserAsync();

            string json = JsonConvert.SerializeObject(request);

            using (HttpContent content = new StringContent(json))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                using (HttpResponseMessage response = await this.Client.PostAsync(YammerService.BuildRequest("messages.json"), content))
                {
                    MessageFeed feed = await YammerService.GetResponseContentAsync <MessageFeed>(response);

                    return(YammerService.ProcessMessages(currentUser, feed));
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the activity feed, asynchronously.
        /// </summary>
        /// <param name="olderThanId">The older than identifier.</param>
        /// <param name="newerThanId">The newer than identifier.</param>
        /// <param name="limit">The limit.</param>
        /// <returns>
        /// The activity feed task.
        /// </returns>
        private async Task <MessageFeed> GetMessagesAsync(string uri, Threaded?threaded, int olderThanId, int newerThanId, int limit)
        {
            List <string> parameters = new List <string>(3);

            if (threaded.HasValue)
            {
                parameters.Add("threaded");
                parameters.Add(YammerService.ThreadedValues[threaded.Value]);
            }

            if (limit > 0)
            {
                parameters.Add("limit");
                parameters.Add(limit.ToString());
            }

            if (olderThanId > 0)
            {
                parameters.Add("older_than");
                parameters.Add(olderThanId.ToString());
            }

            if (newerThanId > 0)
            {
                parameters.Add("newer_than");
                parameters.Add(newerThanId.ToString());
            }

            // forces all loaded messages to be marked read
            parameters.Add("update_last_seen_message_id");
            parameters.Add("true");

            User currentUser = await this.GetCurrentUserAsync();

            using (HttpResponseMessage response = await this.Client.GetAsync(YammerService.BuildRequest(uri, parameters.ToArray()), HttpCompletionOption.ResponseContentRead))
            {
                MessageFeed feed = await YammerService.GetResponseContentAsync <MessageFeed>(response);

                return(YammerService.ProcessMessages(currentUser, feed));
            }
        }