public async void TestPutRoomMessagesReadAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var getMessagesParameters = new MessagesParameters { Force = true }; var messagesResponse = await Client.GetRoomMessagesAsync(roomId, getMessagesParameters) .ConfigureAwait(false); AssertGetRoomMessagesResponse(messagesResponse); if (messagesResponse.Data == null || !messagesResponse.Data.Any()) { WarnSkip("TestPutRoomMessagesReadAsync"); return; } var messages = messagesResponse.Data; var messageId = messages.LastOrDefault(x => x.Body != "[deleted]").MessasgeId; if (string.IsNullOrEmpty(messageId)) { WarnSkip("TestPutRoomMessagesReadAsync"); return; } var parameters = new TargetMessageParameters { MessageId = messageId }; var response = await Client .PutRoomMessagesReadAsync(roomId, parameters) .ConfigureAwait(false); AssertPutRoomMessagesReadResponse(response); }
public void TestStaticPutRoomMessagesRead() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var getMessagesParameters = new MessagesParameters { Force = true }; var messagesResponse = ChatworkClient.GetRoomMessages(Token, roomId, getMessagesParameters); AssertGetRoomMessagesResponse(messagesResponse); if (messagesResponse.Data == null || !messagesResponse.Data.Any()) { WarnSkip("TestStaticPutRoomMessagesRead"); return; } var messages = messagesResponse.Data; var messageId = messages.LastOrDefault(x => x.Body != "[deleted]").MessasgeId; if (string.IsNullOrEmpty(messageId)) { WarnSkip("TestStaticPutRoomMessagesRead"); return; } var parameters = new TargetMessageParameters { MessageId = messageId }; var response = ChatworkClient.PutRoomMessagesRead(Token, roomId, parameters); AssertPutRoomMessagesReadResponse(response); }
public void TestStaticGetRoomMembers() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var response = ChatworkClient.GetRoomMembers(Token, roomId); AssertGetRoomMembersResponse(response, AccountId); }
public async void TestStaticGetRoomMembersAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var response = await ChatworkClient.GetRoomMembersAsync(Token, roomId) .ConfigureAwait(false); AssertGetRoomMembersResponse(response, AccountId); }
public void TestGetRoomMembersAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; Client.GetRoomMembersAsync( response => AssertGetRoomMembersResponse(response, AccountId), roomId); }
public void TestStaticGetRoomMembers() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new MessagesParameters { Force = true }; var response = ChatworkClient.GetRoomMessages(Token, roomId, parameters); AssertGetRoomMessagesResponse(response); }
public void TestMessageLifecycle() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var messageId = TestPostRoomMessage(roomId); TestGetRoomMessage(roomId, messageId); TestPutRoomMessage(roomId, messageId); TestDeleteRoomMessage(roomId, messageId); // [POST] /rooms/{room_id}/messages. string TestPostRoomMessage(long roomId) { var parameters = new NewMessageParameters { Body = "new test message.", SelfUnread = true, }; var response = Client.PostRoomMessage(roomId, parameters); AssertPostRoomMessageResponse(response); return(response.Data.MessageId); } // [GET] /rooms/{room_id}/messages/{message_id}. void TestGetRoomMessage(long roomId, string messageId) { var response = Client.GetRoomMessage(roomId, messageId); AssertGetRoomMessageResponse(response, messageId); } // [PUT] /rooms/{room_id}/messages/{message_id}. void TestPutRoomMessage(long roomId, string messageId) { var parameters = new UpdateMessageParameters { Body = "update test message.", }; var response = Client.PutRoomMessage(roomId, messageId, parameters); AssertPutRoomMessageResponse(response, messageId); } // [DELETE] /rooms/{room_id}/messages/{message_id}. void TestDeleteRoomMessage(long roomId, string messageId) { var response = Client.DeleteRoomMessage(roomId, messageId); AssertDeleteRoomMessageResponse(response, messageId); } }
public void TestStaticGetRoomFiles() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new FilesParameters { AccountId = AccountId, }; var response = ChatworkClient.GetRoomFiles(Token, roomId, parameters); AssertGetFilesResponse(response); }
public void TestRoomsRoomLink() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var link = TestGetRoomLink(roomId); var linkExists = link.Public || link.Url != null || !string.IsNullOrEmpty(link.Description); if (linkExists) { TestPutRoomLink(roomId); TestDeleteRoomLink(roomId); TestPostRoomLink(roomId); } else { TestPostRoomLink(roomId); TestPutRoomLink(roomId); TestDeleteRoomLink(roomId); } // [GET] /rooms/{room_id}/link. LinkData TestGetRoomLink(long roomId) { var response = Client.GetRoomLink(roomId); AssertGetRoomLinkResponse(response); return(response.Data); } // [POST] /rooms/{room_id}/link. void TestPostRoomLink(long roomId) { var response = Client.PostRoomLink(roomId, newLinkParameters); AssertPostRoomLinkResponse(response); } // [PUT] /rooms/{room_id}/link. void TestPutRoomLink(long roomId) { var response = Client.PutRoomLink(roomId, updateLinkParameters); AssertPutRoomLinkResponse(response); } // [DELETE] /rooms/{room_id}/link. void TestDeleteRoomLink(long roomId) { var response = Client.DeleteRoomLink(roomId); AssertDeleteRoomLinkResponse(response); } }
public async void TestStaticGetRoomMessagesAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new MessagesParameters { Force = true }; var response = await ChatworkClient .GetRoomMessagesAsync(Token, roomId, parameters) .ConfigureAwait(false); AssertGetRoomMessagesResponse(response); }
public void TestGetRoomMessagesAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new MessagesParameters { Force = true }; Client.GetRoomMessagesAsync( AssertGetRoomMessagesResponse, roomId, parameters); }
public async void TestGetRoomFilesAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new FilesParameters { AccountId = AccountId, }; var response = await Client.GetRoomFilesAsync(roomId, parameters) .ConfigureAwait(false); AssertGetFilesResponse(response); }
public void TestGetRoomFilesAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new FilesParameters { AccountId = AccountId, }; Client.GetRoomFilesAsync( AssertGetFilesResponse, roomId, parameters); }
public void TestStaticRoomFileLifecycle() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var newParameters = textFileContent; var newResponse = ChatworkClient.PostRoomFile(Token, roomId, newParameters); AssertPostFileResponse(newResponse); var fileId = newResponse.Data.FileId; var parameters = new FileParameters { CreateDownloadUrl = true, }; var response = ChatworkClient.GetRoomFile(Token, roomId, fileId, parameters); AssertGetFileResponse(response, fileId); }
public async Task LoadRooms() { isLoading = true; if (!RoomList.Any()) { var temp = await httpClient.GetAsync(@"api/room"); Console.WriteLine(await temp.Content.ReadAsStringAsync()); var temp2 = JsonConvert.DeserializeObject <List <Room> >(await temp.Content.ReadAsStringAsync(), new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); Console.WriteLine(temp2); RoomList = temp2; foreach (var room in RoomList) { Console.WriteLine(room.Id); } } isLoading = false; }
public async void TestRoomFileLifecycleAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var newParameters = textFileContent; var newResponse = await Client.PostRoomFileAsync(roomId, newParameters) .ConfigureAwait(false); AssertPostFileResponse(newResponse); var fileId = newResponse.Data.FileId; var parameters = new FileParameters { CreateDownloadUrl = true, }; var response = await Client.GetRoomFileAsync(roomId, fileId, parameters) .ConfigureAwait(false); AssertGetFileResponse(response, fileId); }
public void TestPutRoomMessagesUnreadAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var getMessagesParameters = new MessagesParameters { Force = true }; Client.GetRoomMessagesAsync( messagesResponse => { AssertGetRoomMessagesResponse(messagesResponse); if (messagesResponse.Data == null || !messagesResponse.Data.Any()) { WarnSkip("TestPutRoomMessagesUnreadAsync"); return; } var messages = messagesResponse.Data; var messageId = messages.FirstOrDefault(x => x.Body != "[deleted]").MessasgeId; if (string.IsNullOrEmpty(messageId)) { WarnSkip("TestPutRoomMessagesUnreadAsync"); return; } var parameters = new TargetMessageParameters { MessageId = messageId }; Client.PutRoomMessagesUnreadAsync( AssertPutRoomMessagesUnreadResponse, roomId, parameters); }, roomId, getMessagesParameters); }
public void TestStaticRoomFileLifecycleAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; TestStaticPostRoomFileAsyncCallback(roomId, TestStaticGetRoomFileAsyncCallback); // [POST] /rooms/{room_id}/files. void TestStaticPostRoomFileAsyncCallback(long roomId, Action <long, long> next) { var parameters = textFileContent; ChatworkClient.PostRoomFileAsync( Token, response => { AssertPostFileResponse(response); next.Invoke(roomId, response.Data.FileId); }, roomId, parameters); } // [GET] /rooms/{room_id}/files/{file_id}. void TestStaticGetRoomFileAsyncCallback(long roomId, long fileId) { var parameters = new FileParameters { CreateDownloadUrl = true, }; ChatworkClient.GetRoomFileAsync( Token, response => AssertGetFileResponse(response, fileId), roomId, fileId, parameters); } }
public void TestRoomTaskLifecycle() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var taskIdList = TestGetRoomTasks(roomId); var extendedTaskIdList = TestPostRoomTasks(roomId); var taskId = extendedTaskIdList.FirstOrDefault(x => !taskIdList.Contains(x)); TestGetRoomTask(roomId, taskId); TestPutRoomTaskStatus(roomId, taskId); // [GET] /rooms/{room_id}/tasks. IReadOnlyCollection <long> TestGetRoomTasks(long roomId) { var parameters = new RoomTasksParameters { AccountId = AccountId, AssignedByAccontId = AccountId, Status = TaskStatusValue.Open, }; var response = Client.GetRoomTasks(roomId, parameters); AssertGetRoomTasksResponse(response); return(response.Data ?.Select(x => x.TaskId).ToArray() ?? Array.Empty <long>()); } // [POST] /rooms/{room_id}/tasks. IReadOnlyCollection <long> TestPostRoomTasks(long roomId) { var now = DateTime.Now; var parameters = new NewRoomTaskParameters { Body = $"task test {now.Ticks}", Limit = now + TimeSpan.FromMinutes(60), LimitType = LimitTypeValue.Date, ToIds = MemberList, }; var response = Client.PostRoomTask(roomId, parameters); AssertPostRoomTasksResponse(response); return(response.Data.TaskIds ?? Array.Empty <long>()); } // [GET] /rooms/{room_id}/tasks/{task_id}. void TestGetRoomTask(long roomId, long taskId) { var response = Client.GetRoomTask(roomId, taskId); AssertGetRoomTaskResponse(response, taskId); } // [PUT] /rooms/{room_id}/tasks/{task_id}. void TestPutRoomTaskStatus(long roomId, long taskId) { var parameters = new UpdateRoomTaskStatusParameters { Body = TaskStatusValue.Done, }; var response = Client.PutRoomTaskStatus(roomId, taskId, parameters); AssertPutRoomTaskStatusResponse(response, taskId); } }
public async void TestStaticMessageLifecycleAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var messageId = await TestStaticPostRoomMessageAsync(roomId) .ConfigureAwait(false); await TestStaticGetRoomMessageAsync(roomId, messageId) .ConfigureAwait(false); await TestStaticPutRoomMessageAsync(roomId, messageId) .ConfigureAwait(false); await TestStaticDeleteRoomMessageAsync(roomId, messageId) .ConfigureAwait(false); // [POST] /rooms/{room_id}/messages. async Task <string> TestStaticPostRoomMessageAsync(long roomId) { var parameters = new NewMessageParameters { Body = "new test message.", SelfUnread = true, }; var response = await ChatworkClient.PostRoomMessageAsync(Token, roomId, parameters) .ConfigureAwait(false); AssertPostRoomMessageResponse(response); return(response.Data.MessageId); } // [GET] /rooms/{room_id}/messages/{message_id}. async Task TestStaticGetRoomMessageAsync(long roomId, string messageId) { var response = await ChatworkClient.GetRoomMessageAsync(Token, roomId, messageId) .ConfigureAwait(false); AssertGetRoomMessageResponse(response, messageId); } // [PUT] /rooms/{room_id}/messages/{message_id}. async Task TestStaticPutRoomMessageAsync(long roomId, string messageId) { var parameters = new UpdateMessageParameters { Body = "update test message.", }; var response = await ChatworkClient.PutRoomMessageAsync(Token, roomId, messageId, parameters) .ConfigureAwait(false); AssertPutRoomMessageResponse(response, messageId); } // [DELETE] /rooms/{room_id}/messages/{message_id}. async Task TestStaticDeleteRoomMessageAsync(long roomId, string messageId) { var response = await ChatworkClient.DeleteRoomMessageAsync(Token, roomId, messageId) .ConfigureAwait(false); AssertDeleteRoomMessageResponse(response, messageId); } }
public void TestStaticRoomsRoomLinkAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; TestStaticGetRoomLinkAsyncCallback( roomId, (roomId, link) => { var linkExists = link.Public || link.Url != null || !string.IsNullOrEmpty(link.Description); if (linkExists) { TestStaticPutRoomLinkAsyncCallback( roomId, roomId => { TestStaticDeleteRoomLinkAsyncCallback( roomId, roomId => { TestStaticPostRoomLinkAsyncCallback(roomId, null); }); }); } else { TestStaticPostRoomLinkAsyncCallback( roomId, roomId => { TestStaticPutRoomLinkAsyncCallback( roomId, roomId => { TestStaticDeleteRoomLinkAsyncCallback(roomId, null); }); }); } }); // [GET] /rooms/{room_id}/link. void TestStaticGetRoomLinkAsyncCallback(long roomId, Action <long, LinkData> next) { ChatworkClient.GetRoomLinkAsync( Token, response => { AssertGetRoomLinkResponse(response); if (next != null) { next.Invoke(roomId, response.Data); } }, roomId); } // [POST] /rooms/{room_id}/link. void TestStaticPostRoomLinkAsyncCallback(long roomId, Action <long> next) { ChatworkClient.PostRoomLinkAsync( Token, response => { AssertPostRoomLinkResponse(response); if (next != null) { next.Invoke(roomId); } }, roomId, newLinkParameters); } // [PUT] /rooms/{room_id}/link. void TestStaticPutRoomLinkAsyncCallback(long roomId, Action <long> next) { ChatworkClient.PutRoomLinkAsync( Token, response => { AssertPutRoomLinkResponse(response); if (next != null) { next.Invoke(roomId); } }, roomId, updateLinkParameters); } // [DELETE] /rooms/{room_id}/link. void TestStaticDeleteRoomLinkAsyncCallback(long roomId, Action <long> next) { ChatworkClient.DeleteRoomLinkAsync( Token, response => { AssertDeleteRoomLinkResponse(response); if (next != null) { next.Invoke(roomId); } }, roomId); } }
public async void TestStaticRoomsRoomLinkAsync() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var link = await TestStaticGetRoomLinkAsync(roomId) .ConfigureAwait(false); var linkExists = link.Public || link.Url != null || !string.IsNullOrEmpty(link.Description); if (linkExists) { await TestStaticPutRoomLinkAsync(roomId) .ConfigureAwait(false); await TestStaticDeleteRoomLinkAsync(roomId) .ConfigureAwait(false); await TestStaticPostRoomLinkAsync(roomId) .ConfigureAwait(false); } else { await TestStaticPostRoomLinkAsync(roomId) .ConfigureAwait(false); await TestStaticPutRoomLinkAsync(roomId) .ConfigureAwait(false); await TestStaticDeleteRoomLinkAsync(roomId) .ConfigureAwait(false); } // [GET] /rooms/{room_id}/link. async Task <LinkData> TestStaticGetRoomLinkAsync(long roomId) { var response = await ChatworkClient.GetRoomLinkAsync(Token, roomId) .ConfigureAwait(false); AssertGetRoomLinkResponse(response); return(response.Data); } // [POST] /rooms/{room_id}/link. async Task TestStaticPostRoomLinkAsync(long roomId) { var response = await ChatworkClient.PostRoomLinkAsync(Token, roomId, newLinkParameters) .ConfigureAwait(false); AssertPostRoomLinkResponse(response); } // [PUT] /rooms/{room_id}/link. async Task TestStaticPutRoomLinkAsync(long roomId) { var response = await ChatworkClient.PutRoomLinkAsync(Token, roomId, updateLinkParameters) .ConfigureAwait(false); AssertPutRoomLinkResponse(response); } // [DELETE] /rooms/{room_id}/link. async Task TestStaticDeleteRoomLinkAsync(long roomId) { var response = await ChatworkClient.DeleteRoomLinkAsync(Token, roomId) .ConfigureAwait(false); AssertDeleteRoomLinkResponse(response); } }
public void TestStaticMessageLifecycleAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; TestStaticPostRoomMessageAsyncCallback( roomId, (roomId, messageId) => TestStaticGetRoomMessageAsyncCallback( roomId, messageId, (roomId, messageId) => TestStaticPutRoomMessageAsyncCallback( roomId, messageId, TestStaticDeleteRoomMessageAsyncCallback))); // [POST] /rooms/{room_id}/messages. void TestStaticPostRoomMessageAsyncCallback(long roomId, Action <long, string> next) { var parameters = new NewMessageParameters { Body = "new test message.", SelfUnread = true, }; ChatworkClient.PostRoomMessageAsync( Token, response => { AssertPostRoomMessageResponse(response); next.Invoke(roomId, response.Data.MessageId); }, roomId, parameters); } // [GET] /rooms/{room_id}/messages/{message_id}. void TestStaticGetRoomMessageAsyncCallback(long roomId, string messageId, Action <long, string> next) { ChatworkClient.GetRoomMessageAsync( Token, response => { AssertGetRoomMessageResponse(response, messageId); next.Invoke(roomId, messageId); }, roomId, messageId); } // [PUT] /rooms/{room_id}/messages/{message_id}. void TestStaticPutRoomMessageAsyncCallback(long roomId, string messageId, Action <long, string> next) { var parameters = new UpdateMessageParameters { Body = "update test message.", }; ChatworkClient.PutRoomMessageAsync( Token, response => { AssertPutRoomMessageResponse(response, messageId); next.Invoke(roomId, messageId); }, roomId, messageId, parameters); } // [DELETE] /rooms/{room_id}/messages/{message_id}. void TestStaticDeleteRoomMessageAsyncCallback(long roomId, string messageId) { ChatworkClient.DeleteRoomMessageAsync( Token, response => AssertDeleteRoomMessageResponse(response, messageId), roomId, messageId); } }
public void TestStaticRoomTaskLifecycleAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; TestStaticGetRoomTasksAsyncCallback( roomId, taskIdList => TestStaticPostRoomTasksAsyncCallback( roomId, extendedTaskIdList => { var taskId = extendedTaskIdList.FirstOrDefault(x => !taskIdList.Contains(x)); TestStaticGetRoomTaskAsyncCallback(roomId, taskId); TestStaticPutRoomTaskStatusAsyncCallback(roomId, taskId); })); // [GET] /rooms/{room_id}/tasks. void TestStaticGetRoomTasksAsyncCallback(long roomId, Action <IReadOnlyCollection <long> > next) { var parameters = new RoomTasksParameters { AccountId = AccountId, AssignedByAccontId = AccountId, Status = TaskStatusValue.Open, }; ChatworkClient.GetRoomTasksAsync( Token, response => { AssertGetRoomTasksResponse(response); var taskIdList = response.Data ?.Select(x => x.TaskId).ToArray() ?? Array.Empty <long>(); next.Invoke(taskIdList); }, roomId, parameters); } // [POST] /rooms/{room_id}/tasks. void TestStaticPostRoomTasksAsyncCallback(long roomId, Action <IReadOnlyCollection <long> > next) { var now = DateTime.Now; var parameters = new NewRoomTaskParameters { Body = $"task test {now.Ticks}", Limit = now + TimeSpan.FromMinutes(60), LimitType = LimitTypeValue.Date, ToIds = MemberList, }; ChatworkClient.PostRoomTaskAsync( Token, response => { AssertPostRoomTasksResponse(response); var taskIdList = response.Data.TaskIds ?? Array.Empty <long>(); next.Invoke(taskIdList); }, roomId, parameters); } // [GET] /rooms/{room_id}/tasks/{task_id}. void TestStaticGetRoomTaskAsyncCallback(long roomId, long taskId) { ChatworkClient.GetRoomTaskAsync( Token, response => AssertGetRoomTaskResponse(response, taskId), roomId, taskId); } // [PUT] /rooms/{room_id}/tasks/{task_id}/status. void TestStaticPutRoomTaskStatusAsyncCallback(long roomId, long taskId) { var parameters = new UpdateRoomTaskStatusParameters { Body = TaskStatusValue.Done, }; ChatworkClient.PutRoomTaskStatusAsync( Token, response => AssertPutRoomTaskStatusResponse(response, taskId), roomId, taskId, parameters); } }