/// <summary> /// 创建聊天室。 /// </summary> /// <param name="chatroomInfo">聊天室对象。</param> /// <returns>Success: 201 Created</returns> public HttpResponse CreateChatroom(ChatroomInfo chatroomInfo) { Task <HttpResponse> task = CreateChatroomAsync(chatroomInfo); task.Wait(); return(task.Result); }
/// <summary> /// 更新聊天室信息。 /// </summary> /// <param name="chatroomInfo">其中 Id 和 Name 属性为必填。</param> public HttpResponse UpdateChatroomInfo(ChatroomInfo chatroomInfo) { Task <HttpResponse> task = UpdateChatroomInfoAsync(chatroomInfo); task.Wait(); return(task.Result); }
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)); }