public async Task <HttpResponse> UpdateChatroomInfoAsync(ChatroomInfo chatroomInfo) { if (chatroomInfo == null) { throw new ArgumentNullException(nameof(chatroomInfo)); } var url = $"/v1/chatroom/{chatroomInfo.Id}"; var httpContent = new StringContent(chatroomInfo.ToString(), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = await JMessageClient.HttpClient.PutAsync(url, httpContent).ConfigureAwait(false); string httpResponseContent = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpResponse(httpResponseMessage.StatusCode, httpResponseMessage.Headers, httpResponseContent)); }
public async Task <HttpResponse> CreateChatroomAsync(ChatroomInfo chatroomInfo) { if (chatroomInfo == null) { throw new ArgumentNullException(nameof(chatroomInfo)); } if (string.IsNullOrEmpty(chatroomInfo.Name)) { throw new ArgumentNullException(nameof(chatroomInfo.Name)); } if (string.IsNullOrEmpty(chatroomInfo.Owner)) { throw new ArgumentNullException(nameof(chatroomInfo.Owner)); } HttpContent httpContent = new StringContent(chatroomInfo.ToString(), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = await JMessageClient.HttpClient.PostAsync("/v1/chatroom/", httpContent).ConfigureAwait(false); string httpResponseContent = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpResponse(httpResponseMessage.StatusCode, httpResponseMessage.Headers, httpResponseContent)); }