public async Task <ReactionResponse> SendReaction(string messageID, Reaction reaction, string userID, bool skipPush = false) { if (reaction.User == null) { reaction.User = new User(); } reaction.User.ID = userID; var payload = new JObject(new JProperty("reaction", reaction.ToJObject())); if (skipPush) { payload.Add("skip_push", true); } var endpoint = string.Format("messages/{0}/reaction", messageID); var request = this._client.BuildAppRequest(endpoint, HttpMethod.POST); request.SetJsonBody(payload.ToString()); var response = await this._client.MakeRequest(request); if (response.StatusCode == System.Net.HttpStatusCode.Created) { var respObj = JObject.Parse(response.Content); return(ReactionResponse.FromJObject(respObj)); } throw StreamChatException.FromResponse(response); }
public async Task <ReactionResponse> DeleteReaction(string messageID, string reactionType, string userID) { var endpoint = string.Format("messages/{0}/reaction/{1}", messageID, reactionType); var request = this._client.BuildAppRequest(endpoint, HttpMethod.DELETE); request.AddQueryParameter("user_id", userID); var response = await this._client.MakeRequest(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var respObj = JObject.Parse(response.Content); return(ReactionResponse.FromJObject(respObj)); } throw StreamChatException.FromResponse(response); }
internal static ReactionResponse FromJObject(JObject jObj) { var result = new ReactionResponse(); var data = JsonHelpers.FromJObject(result, jObj); var msgObj = data.GetData <JObject>("message"); if (msgObj != null) { result.Message = Message.FromJObject(msgObj); } var reactionObj = data.GetData <JObject>("reaction"); if (reactionObj != null) { result.Reaction = Reaction.FromJObject(reactionObj); } return(result); }