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 async void TestStaticGetContactsAsync() { var response = await ChatworkClient.GetContactsAsync(Token) .ConfigureAwait(false); AssertGetContactsResponse(response); }
/// <summary> /// A simple function that takes a string and does a ToUpper /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <int> FunctionHandler(ChatworkInput input, ILambdaContext context) { context.Logger.LogLine($"{nameof(SendToChatwork)} was triggered"); if (input.Channel == 0) { throw new ArgumentOutOfRangeException(nameof(input.Channel)); } if (string.IsNullOrWhiteSpace(input.Text)) { throw new ArgumentOutOfRangeException(nameof(input.Text)); } if (string.IsNullOrWhiteSpace(chatworkApiKey)) { throw new NullReferenceException(nameof(chatworkApiKey)); } var roomId = input.Channel; var body = input.Text; var client = new ChatworkClient(chatworkApiKey); var response = await client.Room.SendMessgesAsync(roomId, body); return(response.message_id); }
public void TestStaticGetRoomMembers() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var response = ChatworkClient.GetRoomMembers(Token, roomId); AssertGetRoomMembersResponse(response, AccountId); }
public static async Task <HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) { log.Info($"Webhook was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); if (data.channel == 0 || data.text == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass channel/text properties in the input object" })); } int roomId = data.channel; string body = data.text; var client = new ChatworkClient(chatworkApiKey); await client.Room.SendMessgesAsync(roomId, body); return(req.CreateResponse(HttpStatusCode.OK, new { RoomId = roomId, Message = body, })); }
public async void TestStaticGetMeAsync() { var response = await ChatworkClient.GetMeAsync(Token) .ConfigureAwait(false); AssertGetMeResponse(response, Room, 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 TestStaticIncomingRequestsGetPutDelete() { var data = TestStaticGetIncomingRequest(); if (data == null || !data.Any()) { WarnSkip("TestStaticPutIncomingRequest"); WarnSkip("TestStaticDeleteIncomingRequest"); return; } var requests = data.ToArray(); if (requests.Length > 0) { var requestId = requests[0].RequestId; TestStaticPutIncomingRequest(requestId); } else { WarnSkip("TestStaticPutIncomingRequest"); } if (requests.Length > 1) { var requestId = requests[1].RequestId; TestStaticDeleteIncomingRequest(requestId); } else { WarnSkip("TestStaticDeleteIncomingRequest"); } // [GET] /incoming_requests. IReadOnlyCollection <IncomingRequestData> TestStaticGetIncomingRequest() { var response = ChatworkClient.GetIncomingRequests(Token); AssertGetIncomingRequestsResponse(response); return(response.Data); } // [PUT] /incoming_requests/{request_id}. void TestStaticPutIncomingRequest(long requestId) { var response = ChatworkClient.PutIncomingRequest(Token, requestId); AssertPutIncomingRequestResponse(response); } // [DELETE] /incoming_requests/{request_id}. void TestStaticDeleteIncomingRequest(long requestId) { var response = ChatworkClient.DeleteIncomingRequest(Token, requestId); AssertDeleteIncomingRequestResponse(response); } }
public void TestStaticGetRoomMembersAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; ChatworkClient.GetRoomMembersAsync( Token, 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 TestStaticMessageLifecycle() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var messageId = TestStaticPostRoomMessage(roomId); TestStaticGetRoomMessage(roomId, messageId); TestStaticPutRoomMessage(roomId, messageId); TestStaticDeleteRoomMessage(roomId, messageId); // [POST] /rooms/{room_id}/messages. string TestStaticPostRoomMessage(long roomId) { var parameters = new NewMessageParameters { Body = "new test message.", SelfUnread = true, }; var response = ChatworkClient.PostRoomMessage(Token, roomId, parameters); AssertPostRoomMessageResponse(response); return(response.Data.MessageId); } // [GET] /rooms/{room_id}/messages/{message_id}. void TestStaticGetRoomMessage(long roomId, string messageId) { var response = ChatworkClient.GetRoomMessage(Token, roomId, messageId); AssertGetRoomMessageResponse(response, messageId); } // [PUT] /rooms/{room_id}/messages/{message_id}. void TestStaticPutRoomMessage(long roomId, string messageId) { var parameters = new UpdateMessageParameters { Body = "update test message.", }; var response = ChatworkClient.PutRoomMessage(Token, roomId, messageId, parameters); AssertPutRoomMessageResponse(response, messageId); } // [DELETE] /rooms/{room_id}/messages/{message_id}. void TestStaticDeleteRoomMessage(long roomId, string messageId) { var response = ChatworkClient.DeleteRoomMessage(Token, roomId, messageId); AssertDeleteRoomMessageResponse(response, messageId); } }
public void TestStaticGetMyTasks() { var parameters = new MyTasksParameters { Status = TaskStatusValue.Done, }; var response = ChatworkClient.GetMyTasks(Token, parameters); AssertGetMyTasksResponse(response); }
public void TestStaticGetMyTasksAsyncCallback() { var parameters = new MyTasksParameters { Status = TaskStatusValue.Done, }; ChatworkClient.GetMyTasksAsync( Token, AssertGetMyTasksResponse, parameters); }
public async void TestStaticGetMyTasksAsync() { var parameters = new MyTasksParameters { Status = TaskStatusValue.Done, }; var response = await ChatworkClient.GetMyTasksAsync(Token, parameters) .ConfigureAwait(false); AssertGetMyTasksResponse(response); }
public void TestStaticRoomsRoomLink() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var link = TestStaticGetRoomLink(roomId); var linkExists = link.Public || link.Url != null || !string.IsNullOrEmpty(link.Description); if (linkExists) { TestStaticPutRoomLink(roomId); TestStaticDeleteRoomLink(roomId); TestStaticPostRoomLink(roomId); } else { TestStaticPostRoomLink(roomId); TestStaticPutRoomLink(roomId); TestStaticDeleteRoomLink(roomId); } // [GET] /rooms/{room_id}/link. LinkData TestStaticGetRoomLink(long roomId) { var response = ChatworkClient.GetRoomLink(Token, roomId); AssertGetRoomLinkResponse(response); return(response.Data); } // [POST] /rooms/{room_id}/link. void TestStaticPostRoomLink(long roomId) { var response = ChatworkClient.PostRoomLink(Token, roomId, newLinkParameters); AssertPostRoomLinkResponse(response); } // [PUT] /rooms/{room_id}/link. void TestStaticPutRoomLink(long roomId) { var response = ChatworkClient.PutRoomLink(Token, roomId, updateLinkParameters); AssertPutRoomLinkResponse(response); } // [DELETE] /rooms/{room_id}/link. void TestStaticDeleteRoomLink(long roomId) { var response = ChatworkClient.DeleteRoomLink(Token, roomId); AssertDeleteRoomLinkResponse(response); } }
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 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 TestStaticGetRoomMessagesAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new MessagesParameters { Force = true }; ChatworkClient.GetRoomMessagesAsync( Token, AssertGetRoomMessagesResponse, roomId, parameters); }
public void TestStaticGetRoomFilesAsyncCallback() { var roomId = RoomList != null && RoomList.Any() ? RoomList.First() : Room; var parameters = new FilesParameters { AccountId = AccountId, }; ChatworkClient.GetRoomFilesAsync( Token, AssertGetFilesResponse, roomId, parameters); }
public void TestStaticPutRoomMembers() { Assert.NotEmpty(RoomList); var roomId = RoomList.First(); var parameters = new UpdateRoomMembersParameters { MembersAdminIds = new long[] { AccountId }, MembersMemberIds = null, MembersReadonlyIds = MemberList, }; var response = ChatworkClient.PutRoomMembers(Token, roomId, parameters); AssertPutRoomMembersResponse(response, AccountId); }
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 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 TestStaticGetMe() { var response = ChatworkClient.GetMe(Token); AssertGetMeResponse(response, Room, AccountId); }
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); } }
static void Main(string[] args) { var token = ConfigurationManager.AppSettings["Token"]; if (string.IsNullOrEmpty(token)) { Console.WriteLine("Input auth key:"); token = Console.ReadLine(); } var client = new ChatworkClient(token); var me = client.Me.GetAsync().Result; Console.WriteLine("APIの制限回数:{0},残り:{1},リセット:{2}", client.Limit, client.RemainingLimit, client.ResetTime); Console.WriteLine("あなたの所属:{0},氏名:{1},ID:{2}", me.organization_name, me.name, me.account_id); var users = client.Room.GetRoomMembersAsync(2962030).Result; users.Select(u => u.account_id + " " + u.name) .ToList() .ForEach(Console.WriteLine); var mystatus = client.My.GetStatusAsync().Result; Console.WriteLine("未読数:{0},未読TO数:{1},タスク数:{2}", mystatus.unread_num, mystatus.mention_num, mystatus.mytask_num); var mytasks = client.My.GetTasksAsync().Result; Console.WriteLine(); Console.WriteLine("タスク一覧"); mytasks.OrderBy(task => task.task_id).Select(task => string.Format("{0}:{1} 納期:{2}", task.task_id, task.body, task.limit_time)).ToList().ForEach(Console.WriteLine); Console.WriteLine(); var contacs = client.Contract.GetAsync().Result; Console.WriteLine("あなたのコンタクトには{0}人登録されいます", contacs.Count); var rooms = client.Room.GetAsync().Result; Console.WriteLine(); Console.WriteLine("ルーム一覧"); rooms.OrderBy(r => r.room_id).Select(r => string.Format("{0}:{1}", r.room_id, r.name)).ToList().ForEach(Console.WriteLine); Console.WriteLine(); var mychat = rooms.First(r => r.type == "my"); Console.WriteLine("マイチャットのIDは{0}です", mychat.room_id); Console.WriteLine(); var sentMessage = client.Room.SendMessgesAsync(mychat.room_id, "テスト投稿").Result; Console.WriteLine("マイチャットにテスト投稿しました"); var message = client.Room.GetMessageAsync(mychat.room_id, sentMessage.message_id).Result; Console.WriteLine("投稿したメッセージ: {0}", message.body); var createdTaskId = client.Room.CreateTasksAsync(mychat.room_id, "テストタスク", new int[] { me.account_id }, DateTime.Today.AddDays(1)).Result; var createdTask = client.Room.GetTaskInfoAsync(mychat.room_id, createdTaskId.task_ids.First()).Result; Console.WriteLine("作成したタスク: {0}", createdTask.body); var files = client.Room.GetFilesAsync(mychat.room_id).Result; var file = client.Room.GetFilAsync(mychat.room_id, files.First().file_id).Result; Console.WriteLine(file.account.account_id); var fileWithUrl = client.Room.GetFilAsync(mychat.room_id, files.First().file_id, true).Result; Console.WriteLine("ダウロードURL(30sec有効): " + fileWithUrl.download_url); var messages = client.Room.GetMessagesAsync(6853423).Result; Console.WriteLine(string.Join("\r\n", messages.Select(m => m.message_id + " " + m.body))); messages = client.Room.GetMessagesAsync(6853423, true).Result; Console.WriteLine(string.Join("\r\n", messages.Select(m => m.message_id + " " + m.body))); Console.WriteLine("何かキーを押して終了してください..."); Console.ReadKey(); }
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); } }
public async void TestStaticIncomingRequestsGetPutDeleteAsync() { var data = await TestStaticGetIncomingRequestsAsync() .ConfigureAwait(false); if (data == null || !data.Any()) { WarnSkip("TestStaticPutIncomingRequestAsync"); WarnSkip("TestStaticDeleteIncomingRequestAsync"); return; } var requests = data.ToArray(); if (requests.Length > 0) { var requestId = requests[0].RequestId; await TestStaticPutIncomingRequestAsync(requestId) .ConfigureAwait(false); } else { WarnSkip("TestStaticPutIncomingRequestAsync"); } if (requests.Length > 1) { var requestId = requests[1].RequestId; await TestStaticDeleteIncomingRequestAsync(requestId) .ConfigureAwait(false); } else { WarnSkip("TestStaticDeleteIncomingRequestAsync"); } // [GET] /incoming_requests asynchronously. async Task <IReadOnlyCollection <IncomingRequestData> > TestStaticGetIncomingRequestsAsync() { var response = await ChatworkClient.GetIncomingRequestsAsync(Token) .ConfigureAwait(false); AssertGetIncomingRequestsResponse(response); return(response.Data); } // [PUT] /incoming_requests/{request_id}. async Task TestStaticPutIncomingRequestAsync(long requestId) { var response = await ChatworkClient.PutIncomingRequestAsync(Token, requestId) .ConfigureAwait(false); AssertPutIncomingRequestResponse(response); } // [DELETE] /incoming_requests/{request_id}. async Task TestStaticDeleteIncomingRequestAsync(long requestId) { var response = await ChatworkClient.DeleteIncomingRequestAsync(Token, requestId) .ConfigureAwait(false); AssertDeleteIncomingRequestResponse(response); } }
public void TestStaticGetMeAsyncCallback() { ChatworkClient.GetMeAsync( Token, response => AssertGetMeResponse(response, Room, AccountId)); }
public void TestStaticIncomingRequestsGetPutDeleteAsyncCallback() { TestStaticGetIncomingRequestsAsyncCallback(data => { if (data == null || !data.Any()) { WarnSkip("TestStaticPutIncomingRequestAsync"); WarnSkip("TestStaticDeleteIncomingRequestAsync"); return; } var requests = data.ToArray(); if (requests.Length > 0) { var requestId = requests[0].RequestId; TestStaticPutIncomingRequestAsyncCallback(requestId); } else { WarnSkip("TestStaticPutIncomingRequestAsync"); } if (requests.Length > 1) { var requestId = requests[1].RequestId; TestStaticDeleteIncomingRequestAsyncCallback(requestId); } else { WarnSkip("TestStaticDeleteIncomingRequestAsync"); } }); // [GET] /incoming_requests asynchronously. void TestStaticGetIncomingRequestsAsyncCallback(Action <IReadOnlyCollection <IncomingRequestData> > next) { ChatworkClient.GetIncomingRequestsAsync( Token, response => { AssertGetIncomingRequestsResponse(response); next.Invoke(response.Data); }); } // [PUT] /incoming_requests/{request_id}. void TestStaticPutIncomingRequestAsyncCallback(long requestId) { ChatworkClient.PutIncomingRequestAsync( Token, AssertPutIncomingRequestResponse, requestId); } // [DELETE] /incoming_requests/{request_id}. void TestStaticDeleteIncomingRequestAsyncCallback(long requestId) { ChatworkClient.DeleteIncomingRequestAsync( Token, AssertDeleteIncomingRequestResponse, requestId); } }
static void Main(string[] args) { var token = ConfigurationManager.AppSettings["Token"]; if (string.IsNullOrEmpty(token)) { Console.WriteLine("Input auth key:"); token = Console.ReadLine(); } var client = new ChatworkClient(token); var me = client.Me.GetAsync().Result; Console.WriteLine("APIの制限回数:{0},残り:{1},リセット:{2}", client.Limit, client.RemainingLimit, client.ResetTime); Console.WriteLine("あなたの所属:{0},氏名:{1},ID:{2}", me.organization_name, me.name, me.account_id); var users = client.Room.GetRoomMembersAsync(2962030).Result; users.Select(u => u.account_id + " " + u.name) .ToList() .ForEach(Console.WriteLine); var mystatus = client.My.GetStatusAsync().Result; Console.WriteLine("未読数:{0},未読TO数:{1},タスク数:{2}", mystatus.unread_num, mystatus.mention_num, mystatus.mytask_num); var mytasks = client.My.GetTasksAsync().Result; Console.WriteLine(); Console.WriteLine("タスク一覧"); mytasks.OrderBy(task => task.task_id).Select(task => string.Format("{0}:{1} 納期:{2}", task.task_id, task.body, task.limit_time)).ToList().ForEach(Console.WriteLine); Console.WriteLine(); var contacs = client.Contract.GetAsync().Result; Console.WriteLine("あなたのコンタクトには{0}人登録されいます", contacs.Count); var rooms = client.Room.GetAsync().Result; Console.WriteLine(); Console.WriteLine("ルーム一覧"); rooms.OrderBy(r => r.room_id).Select(r => string.Format("{0}:{1}", r.room_id, r.name)).ToList().ForEach(Console.WriteLine); Console.WriteLine(); var mychat = rooms.First(r => r.type == "my"); Console.WriteLine("マイチャットのIDは{0}です", mychat.room_id); Console.WriteLine(); var sentMessage = client.Room.SendMessgesAsync(mychat.room_id, "テスト投稿").Result; Console.WriteLine("マイチャットにテスト投稿しました"); var message = client.Room.GetMessageAsync(mychat.room_id, sentMessage.message_id).Result; Console.WriteLine("投稿したメッセージ: {0}", message.body); var createdTaskId = client.Room.CreateTasksAsync(mychat.room_id, "テストタスク", new int[] { me.account_id }, DateTime.Today.AddDays(1)).Result; var createdTask = client.Room.GetTaskInfoAsync(mychat.room_id, createdTaskId.task_ids.First()).Result; Console.WriteLine("作成したタスク: {0}", createdTask.body); var files = client.Room.GetFilesAsync(mychat.room_id).Result; var file = client.Room.GetFilAsync(mychat.room_id, files.First().file_id).Result; Console.WriteLine(file.account.account_id); var fileWithUrl = client.Room.GetFilAsync(mychat.room_id, files.First().file_id, true).Result; Console.WriteLine("ダウロードURL(30sec有効): " + fileWithUrl.download_url); var messages = client.Room.GetMessagesAsync(6853423).Result; Console.WriteLine(string.Join("\r\n", messages.Select(m => m.message_id + " " + m.body))); messages = client.Room.GetMessagesAsync(6853423, true).Result; Console.WriteLine(string.Join("\r\n", messages.Select(m => m.message_id + " " + m.body))); Console.WriteLine("何かキーを押して終了してください..."); Console.ReadKey(); }