chatwork 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +113 -38
  4. data/lib/chatwork.rb +35 -3
  5. data/lib/chatwork/base_client.rb +9 -4
  6. data/lib/chatwork/client.rb +43 -8
  7. data/lib/chatwork/client/contacts_methods.rb +29 -0
  8. data/lib/chatwork/client/file_methods.rb +67 -0
  9. data/lib/chatwork/client/incoming_request_methods.rb +77 -0
  10. data/lib/chatwork/client/invitation_link_methods.rb +110 -0
  11. data/lib/chatwork/client/me_methods.rb +38 -0
  12. data/lib/chatwork/client/member_methods.rb +64 -0
  13. data/lib/chatwork/client/message_methods.rb +178 -0
  14. data/lib/chatwork/client/my_status_methods.rb +25 -0
  15. data/lib/chatwork/client/my_task_methods.rb +41 -0
  16. data/lib/chatwork/client/room_methods.rb +156 -0
  17. data/lib/chatwork/client/task_methods.rb +109 -0
  18. data/lib/chatwork/contacts.rb +6 -4
  19. data/lib/chatwork/converter.rb +18 -0
  20. data/lib/chatwork/file.rb +12 -6
  21. data/lib/chatwork/incoming_request.rb +18 -8
  22. data/lib/chatwork/invitation_link.rb +24 -20
  23. data/lib/chatwork/me.rb +6 -4
  24. data/lib/chatwork/member.rb +18 -12
  25. data/lib/chatwork/message.rb +42 -16
  26. data/lib/chatwork/my_status.rb +6 -4
  27. data/lib/chatwork/my_task.rb +6 -4
  28. data/lib/chatwork/oauth_client.rb +10 -2
  29. data/lib/chatwork/oauth_client/token_methods.rb +25 -0
  30. data/lib/chatwork/room.rb +37 -20
  31. data/lib/chatwork/task.rb +18 -14
  32. data/lib/chatwork/token.rb +1 -7
  33. data/lib/chatwork/version.rb +1 -1
  34. data/spec/lib/chatwork/client/contacts_methods_spec.rb +11 -0
  35. data/spec/lib/chatwork/client/file_methods_spec.rb +37 -0
  36. data/spec/lib/chatwork/client/incoming_request_methods_spec.rb +35 -0
  37. data/spec/lib/chatwork/client/invitation_link_methods_spec.rb +71 -0
  38. data/spec/lib/chatwork/client/me_methods_spec.rb +21 -0
  39. data/spec/lib/chatwork/client/member_methods_spec.rb +47 -0
  40. data/spec/lib/chatwork/client/message_methods_spec.rb +102 -0
  41. data/spec/lib/chatwork/client/my_status_methods_spec.rb +11 -0
  42. data/spec/lib/chatwork/client/my_task_methods_spec.rb +20 -0
  43. data/spec/lib/chatwork/client/room_methods_spec.rb +111 -0
  44. data/spec/lib/chatwork/client/task_methods_spec.rb +80 -0
  45. data/spec/lib/chatwork/client_spec.rb +8 -1
  46. data/spec/lib/chatwork/contacts_spec.rb +2 -2
  47. data/spec/lib/chatwork/{entity_methods_spec.rb → converter_spec.rb} +2 -2
  48. data/spec/lib/chatwork/file_spec.rb +2 -2
  49. data/spec/lib/chatwork/incoming_request_spec.rb +3 -3
  50. data/spec/lib/chatwork/invitation_link_spec.rb +4 -2
  51. data/spec/lib/chatwork/me_spec.rb +3 -21
  52. data/spec/lib/chatwork/member_spec.rb +2 -1
  53. data/spec/lib/chatwork/message_spec.rb +7 -7
  54. data/spec/lib/chatwork/my_status_spec.rb +1 -1
  55. data/spec/lib/chatwork/my_task_spec.rb +1 -0
  56. data/spec/lib/chatwork/{token_spec.rb → oauth_client/token_methods_spec.rb} +4 -7
  57. data/spec/lib/chatwork/oauth_client_spec.rb +7 -1
  58. data/spec/lib/chatwork/room_spec.rb +5 -2
  59. data/spec/lib/chatwork/task_spec.rb +3 -0
  60. data/spec/support/contexts/api_context.rb +4 -3
  61. data/spec/support/examples/a_chatwork_api.rb +22 -5
  62. data/spec/support/utils/raml_parser.rb +2 -3
  63. metadata +42 -8
  64. data/lib/chatwork/entity_methods.rb +0 -36
@@ -0,0 +1,25 @@
1
+ module ChatWork::Client::MyStatusMethods
2
+ # Get the number of: unread messages, unread To messages, and unfinished tasks.
3
+ #
4
+ # @see http://developer.chatwork.com/ja/endpoint_my.html#GET-my-status
5
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
6
+ #
7
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
8
+ # @yieldparam response_body [Hashie::Mash] response body
9
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
10
+ #
11
+ # @return [Hashie::Mash]
12
+ #
13
+ # @example response format
14
+ # {
15
+ # "unread_room_num": 2,
16
+ # "mention_room_num": 1,
17
+ # "mytask_room_num": 3,
18
+ # "unread_num": 12,
19
+ # "mention_num": 1,
20
+ # "mytask_num": 8
21
+ # }
22
+ def get_my_status(&block)
23
+ get("/my/status", &block)
24
+ end
25
+ end
@@ -0,0 +1,41 @@
1
+ module ChatWork::Client::MyTaskMethods
2
+ # Get the list of all unfinished tasks
3
+ #
4
+ # (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
5
+ #
6
+ # @see http://developer.chatwork.com/ja/endpoint_my.html#GET-my-tasks
7
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
8
+ #
9
+ # @param assigned_by_account_id [Integer] Account ID of the person who assigned task
10
+ # @param status [String] Task status (open, done)
11
+ #
12
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
13
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
14
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
15
+ #
16
+ # @return [Array<Hashie::Mash>]
17
+ #
18
+ # @example response format
19
+ # [
20
+ # {
21
+ # "task_id": 3,
22
+ # "room": {
23
+ # "room_id": 5,
24
+ # "name": "Group Chat Name",
25
+ # "icon_path": "https://example.com/ico_group.png"
26
+ # },
27
+ # "assigned_by_account": {
28
+ # "account_id": 456,
29
+ # "name": "Anna",
30
+ # "avatar_image_url": "https://example.com/def.png"
31
+ # },
32
+ # "message_id": "13",
33
+ # "body": "buy milk",
34
+ # "limit_time": 1384354799,
35
+ # "status": "open"
36
+ # }
37
+ # ]
38
+ def get_my_tasks(assigned_by_account_id: nil, status: nil, &block)
39
+ get("/my/tasks", assigned_by_account_id: assigned_by_account_id, status: status, &block)
40
+ end
41
+ end
@@ -0,0 +1,156 @@
1
+ module ChatWork::Client::RoomMethods
2
+ # Get the list of all chats on your account
3
+ #
4
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms
5
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
6
+ #
7
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
8
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
9
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
10
+ #
11
+ # @return [Array<Hashie::Mash>]
12
+ #
13
+ # @example response format
14
+ # [
15
+ # {
16
+ # "room_id": 123,
17
+ # "name": "Group Chat Name",
18
+ # "type": "group",
19
+ # "role": "admin",
20
+ # "sticky": false,
21
+ # "unread_num": 10,
22
+ # "mention_num": 1,
23
+ # "mytask_num": 0,
24
+ # "message_num": 122,
25
+ # "file_num": 10,
26
+ # "task_num": 17,
27
+ # "icon_path": "https://example.com/ico_group.png",
28
+ # "last_update_time": 1298905200
29
+ # }
30
+ # ]
31
+ def get_rooms(&block)
32
+ get("/rooms", &block)
33
+ end
34
+
35
+ # rubocop:disable Metrics/ParameterLists
36
+
37
+ # Create a new group chat
38
+ #
39
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms
40
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
41
+ #
42
+ # @param description [String] Description of the group chat
43
+ # @param icon_preset [String] Type of the group chat icon (group, check, document, meeting, event, project, business,
44
+ # study, security, star, idea, heart, magcup, beer, music, sports, travel)
45
+ # @param members_admin_ids [Array<Integer>, String] List of user IDs who will be given administrator permission for the group chat.
46
+ # At least one user must be specified as an administrator.
47
+ # @param members_member_ids [Array<Integer>, String] List of user IDs who will be given member permission for the group chat.
48
+ # @param members_readonly_ids [Array<Integer>, String] List of user IDs who will be given read-only permission for the group chat.
49
+ # @param name [String] Title of the group chat.
50
+ # @param link [Boolean] whether create invitation link
51
+ # @param link_code [String] link path (default. random string)
52
+ # @param link_need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
53
+ #
54
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
55
+ # @yieldparam response_body [Hashie::Mash] response body
56
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
57
+ #
58
+ # @return [Hashie::Mash]
59
+ #
60
+ # @example response format
61
+ # {
62
+ # "room_id": 1234
63
+ # }
64
+ def create_room(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:,
65
+ link: nil, link_code: nil, link_need_acceptance: nil, &block)
66
+ params = {
67
+ description: description,
68
+ icon_preset: icon_preset,
69
+ members_admin_ids: Array(members_admin_ids).join(","),
70
+ name: name,
71
+ link: boolean_to_integer(link),
72
+ link_need_acceptance: boolean_to_integer(link_need_acceptance),
73
+ link_code: link_code,
74
+ }
75
+ params[:members_member_ids] = Array(members_member_ids).join(",") if members_member_ids
76
+ params[:members_readonly_ids] = Array(members_readonly_ids).join(",") if members_readonly_ids
77
+
78
+ post("/rooms", params, &block)
79
+ end
80
+
81
+ # rubocop:enable Metrics/ParameterLists
82
+
83
+ # Get chat name, icon, and Type (my, direct, or group)
84
+ #
85
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id
86
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
87
+ #
88
+ # @param room_id [Integer]
89
+ #
90
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
91
+ # @yieldparam response_body [Hashie::Mash] response body
92
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
93
+ #
94
+ # @return [Hashie::Mash]
95
+ #
96
+ # @example response format
97
+ # {
98
+ # "room_id": 123,
99
+ # "name": "Group Chat Name",
100
+ # "type": "group",
101
+ # "role": "admin",
102
+ # "sticky": false,
103
+ # "unread_num": 10,
104
+ # "mention_num": 1,
105
+ # "mytask_num": 0,
106
+ # "message_num": 122,
107
+ # "file_num": 10,
108
+ # "task_num": 17,
109
+ # "icon_path": "https://example.com/ico_group.png",
110
+ # "last_update_time": 1298905200,
111
+ # "description": "room description text"
112
+ # }
113
+ def find_room(room_id:, &block)
114
+ get("/rooms/#{room_id}", &block)
115
+ end
116
+
117
+ # Change the title and icon type of the specified chat
118
+ #
119
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id
120
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
121
+ #
122
+ # @param room_id [Integer]
123
+ # @param description [String] Description of the group chat
124
+ # @param icon_preset [String] Type of the group chat icon (group, check, document, meeting, event, project, business,
125
+ # study, security, star, idea, heart, magcup, beer, music, sports, travel)
126
+ # @param name [String] Title of the group chat.
127
+ #
128
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
129
+ # @yieldparam response_body [Hashie::Mash] response body
130
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
131
+ #
132
+ # @return [Hashie::Mash]
133
+ #
134
+ # @example response format
135
+ # {
136
+ # "room_id": 1234
137
+ # }
138
+ def update_room(room_id:, description: nil, icon_preset: nil, name: nil, &block)
139
+ put("/rooms/#{room_id}", description: description, icon_preset: icon_preset, name: name, &block)
140
+ end
141
+
142
+ # Leave/Delete a group chat
143
+ #
144
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#DELETE-rooms-room_id
145
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
146
+ #
147
+ # @param room_id [Integer]
148
+ # @param action_type [String] leave from a room or delete a room (leave, delete)
149
+ #
150
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
151
+ # @yieldparam response_body [Hashie::Mash] response body
152
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
153
+ def destroy_room(room_id:, action_type:, &block)
154
+ delete("/rooms/#{room_id}", action_type: action_type, &block)
155
+ end
156
+ end
@@ -0,0 +1,109 @@
1
+ module ChatWork::Client::TaskMethods
2
+ # Get the list of tasks associated with the specified chat
3
+ #
4
+ # (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
5
+ #
6
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-tasks
7
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
8
+ #
9
+ # @param room_id [Integer]
10
+ # @param account_id [Integer]
11
+ # @param assigned_by_account_id [Integer] Account ID of the person who assigned task
12
+ # @param status [String] Task status (open, done)
13
+ #
14
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
15
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
16
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
17
+ #
18
+ # @return [Array<Hashie::Mash>]
19
+ #
20
+ # @example response format
21
+ # [
22
+ # {
23
+ # "task_id": 3,
24
+ # "account": {
25
+ # "account_id": 123,
26
+ # "name": "Bob",
27
+ # "avatar_image_url": "https://example.com/abc.png"
28
+ # },
29
+ # "assigned_by_account": {
30
+ # "account_id": 456,
31
+ # "name": "Anna",
32
+ # "avatar_image_url": "https://example.com/def.png"
33
+ # },
34
+ # "message_id": "13",
35
+ # "body": "buy milk",
36
+ # "limit_time": 1384354799,
37
+ # "status": "open"
38
+ # }
39
+ # ]
40
+ def get_tasks(room_id:, account_id:, assigned_by_account_id: nil, status: nil, &block)
41
+ get("/rooms/#{room_id}/tasks", account_id: account_id, assigned_by_account_id: assigned_by_account_id, status: status, &block)
42
+ end
43
+
44
+ # Add a new task to the chat
45
+ #
46
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-tasks
47
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
48
+ #
49
+ # @param room_id [Integer]
50
+ # @param body [String] Task description
51
+ # @param to_ids [Array<Integer>, String] Account ID of the person/people responsible to complete the task
52
+ # @param limit [Time, Integer] When the task is due
53
+ #
54
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
55
+ # @yieldparam response_body [Hashie::Mash] response body
56
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
57
+ #
58
+ # @return [Hashie::Mash]
59
+ #
60
+ # @example response format
61
+ # {
62
+ # "task_ids": [123,124]
63
+ # }
64
+ def create_task(room_id:, body:, to_ids:, limit: nil, &block)
65
+ params = {
66
+ body: body,
67
+ to_ids: Array(to_ids).join(","),
68
+ }
69
+ params[:limit] = limit.to_i if limit
70
+
71
+ post("/rooms/#{room_id}/tasks", params, &block)
72
+ end
73
+
74
+ # Get information about the specified task
75
+ #
76
+ # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-tasks-task_id
77
+ # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
78
+ #
79
+ # @param room_id [Integer]
80
+ # @param task_id [Integer]
81
+ #
82
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
83
+ # @yieldparam response_body [Hashie::Mash] response body
84
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
85
+ #
86
+ # @return [Hashie::Mash]
87
+ #
88
+ # @example response format
89
+ # {
90
+ # "task_id": 3,
91
+ # "account": {
92
+ # "account_id": 123,
93
+ # "name": "Bob",
94
+ # "avatar_image_url": "https://example.com/abc.png"
95
+ # },
96
+ # "assigned_by_account": {
97
+ # "account_id": 456,
98
+ # "name": "Anna",
99
+ # "avatar_image_url": "https://example.com/def.png"
100
+ # },
101
+ # "message_id": "13",
102
+ # "body": "buy milk",
103
+ # "limit_time": 1384354799,
104
+ # "status": "open"
105
+ # }
106
+ def find_task(room_id:, task_id:, &block)
107
+ get("/rooms/#{room_id}/tasks/#{task_id}", &block)
108
+ end
109
+ end
@@ -1,12 +1,14 @@
1
1
  module ChatWork
2
2
  module Contacts
3
- extend EntityMethods
4
-
5
3
  # Get the list of your contacts
6
4
  #
7
5
  # @see http://developer.chatwork.com/ja/endpoint_contacts.html#GET-contacts
8
6
  # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
9
7
  #
8
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
9
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
10
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
11
+ #
10
12
  # @return [Array<Hashie::Mash>]
11
13
  #
12
14
  # @example response format
@@ -22,8 +24,8 @@ module ChatWork
22
24
  # "avatar_image_url": "https://example.com/abc.png"
23
25
  # }
24
26
  # ]
25
- def self.get
26
- _get("/contacts")
27
+ def self.get(&block)
28
+ ChatWork.client.get_contacts(&block)
27
29
  end
28
30
  end
29
31
  end
@@ -0,0 +1,18 @@
1
+ module ChatWork
2
+ module Converter
3
+ def hash_compact(hash)
4
+ hash.reject { |_k, v| v.nil? }
5
+ end
6
+
7
+ def boolean_to_integer(value)
8
+ case value
9
+ when true
10
+ 1
11
+ when false
12
+ 0
13
+ else
14
+ value
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,7 +1,5 @@
1
1
  module ChatWork
2
2
  module File
3
- extend EntityMethods
4
-
5
3
  # Get the list of files associated with the specified chat
6
4
  #
7
5
  # @param room_id [Integer]
@@ -10,6 +8,10 @@ module ChatWork
10
8
  # @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-files
11
9
  # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
12
10
  #
11
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
12
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
13
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
14
+ #
13
15
  # @return [Array<Hashie::Mash>]
14
16
  #
15
17
  # @example response format
@@ -27,8 +29,8 @@ module ChatWork
27
29
  # "upload_time": 1384414750
28
30
  # }
29
31
  # ]
30
- def self.get(room_id:, account_id:)
31
- _get("/rooms/#{room_id}/files", account_id: account_id)
32
+ def self.get(room_id:, account_id:, &block)
33
+ ChatWork.client.get_files(room_id: room_id, account_id: account_id, &block)
32
34
  end
33
35
 
34
36
  # Get information about the specified file
@@ -41,6 +43,10 @@ module ChatWork
41
43
  # @param create_download_url [Boolean] whether or not to create a download link.
42
44
  # If set to true, download like will be created for 30 seconds
43
45
  #
46
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
47
+ # @yieldparam response_body [Hashie::Mash] response body
48
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
49
+ #
44
50
  # @return [Hashie::Mash]
45
51
  #
46
52
  # @example response format
@@ -56,8 +62,8 @@ module ChatWork
56
62
  # "filesize": 2232,
57
63
  # "upload_time": 1384414750
58
64
  # }
59
- def self.find(room_id:, file_id:, create_download_url: nil)
60
- _get("/rooms/#{room_id}/files/#{file_id}", create_download_url: boolean_to_integer(create_download_url))
65
+ def self.find(room_id:, file_id:, create_download_url: nil, &block)
66
+ ChatWork.client.find_file(room_id: room_id, file_id: file_id, create_download_url: create_download_url, &block)
61
67
  end
62
68
  end
63
69
  end
@@ -1,7 +1,5 @@
1
1
  module ChatWork
2
2
  module IncomingRequest
3
- extend EntityMethods
4
-
5
3
  # You can get the list of contact approval request you received
6
4
  #
7
5
  # (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
@@ -9,6 +7,10 @@ module ChatWork
9
7
  # @see http://developer.chatwork.com/ja/endpoint_incoming_requests.html#GET-incoming_requests
10
8
  # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
11
9
  #
10
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
11
+ # @yieldparam response_body [Array<Hashie::Mash>] response body
12
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
13
+ #
12
14
  # @return [Array<Hashie::Mash>]
13
15
  #
14
16
  # @example response format
@@ -25,8 +27,8 @@ module ChatWork
25
27
  # "avatar_image_url": "https://example.com/abc.png"
26
28
  # }
27
29
  # ]
28
- def self.get
29
- _get("/incoming_requests")
30
+ def self.get(&block)
31
+ ChatWork.client.get_incoming_requests(&block)
30
32
  end
31
33
 
32
34
  # You can approve a contact approval request you received
@@ -36,6 +38,10 @@ module ChatWork
36
38
  #
37
39
  # @param request_id [Integer]
38
40
  #
41
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
42
+ # @yieldparam response_body [Hashie::Mash] response body
43
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
44
+ #
39
45
  # @return [Hashie::Mash]
40
46
  #
41
47
  # @example response format
@@ -49,8 +55,8 @@ module ChatWork
49
55
  # "department": "Marketing",
50
56
  # "avatar_image_url": "https://example.com/abc.png"
51
57
  # }
52
- def self.update(request_id:)
53
- _put("/incoming_requests/#{request_id}")
58
+ def self.update(request_id:, &block)
59
+ ChatWork.client.update_incoming_request(request_id: request_id, &block)
54
60
  end
55
61
 
56
62
  # You can decline a contact approval request you received
@@ -59,8 +65,12 @@ module ChatWork
59
65
  # @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
60
66
  #
61
67
  # @param request_id [Integer]
62
- def self.destroy(request_id:)
63
- _delete("/incoming_requests/#{request_id}")
68
+ #
69
+ # @yield [response_body, response_header] if block was given, return response body and response header through block arguments
70
+ # @yieldparam response_body [Hashie::Mash] response body
71
+ # @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
72
+ def self.destroy(request_id:, &block)
73
+ ChatWork.client.destroy_incoming_request(request_id: request_id, &block)
64
74
  end
65
75
 
66
76
  class << self