chatwork 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +113 -38
- data/lib/chatwork.rb +35 -3
- data/lib/chatwork/base_client.rb +9 -4
- data/lib/chatwork/client.rb +43 -8
- data/lib/chatwork/client/contacts_methods.rb +29 -0
- data/lib/chatwork/client/file_methods.rb +67 -0
- data/lib/chatwork/client/incoming_request_methods.rb +77 -0
- data/lib/chatwork/client/invitation_link_methods.rb +110 -0
- data/lib/chatwork/client/me_methods.rb +38 -0
- data/lib/chatwork/client/member_methods.rb +64 -0
- data/lib/chatwork/client/message_methods.rb +178 -0
- data/lib/chatwork/client/my_status_methods.rb +25 -0
- data/lib/chatwork/client/my_task_methods.rb +41 -0
- data/lib/chatwork/client/room_methods.rb +156 -0
- data/lib/chatwork/client/task_methods.rb +109 -0
- data/lib/chatwork/contacts.rb +6 -4
- data/lib/chatwork/converter.rb +18 -0
- data/lib/chatwork/file.rb +12 -6
- data/lib/chatwork/incoming_request.rb +18 -8
- data/lib/chatwork/invitation_link.rb +24 -20
- data/lib/chatwork/me.rb +6 -4
- data/lib/chatwork/member.rb +18 -12
- data/lib/chatwork/message.rb +42 -16
- data/lib/chatwork/my_status.rb +6 -4
- data/lib/chatwork/my_task.rb +6 -4
- data/lib/chatwork/oauth_client.rb +10 -2
- data/lib/chatwork/oauth_client/token_methods.rb +25 -0
- data/lib/chatwork/room.rb +37 -20
- data/lib/chatwork/task.rb +18 -14
- data/lib/chatwork/token.rb +1 -7
- data/lib/chatwork/version.rb +1 -1
- data/spec/lib/chatwork/client/contacts_methods_spec.rb +11 -0
- data/spec/lib/chatwork/client/file_methods_spec.rb +37 -0
- data/spec/lib/chatwork/client/incoming_request_methods_spec.rb +35 -0
- data/spec/lib/chatwork/client/invitation_link_methods_spec.rb +71 -0
- data/spec/lib/chatwork/client/me_methods_spec.rb +21 -0
- data/spec/lib/chatwork/client/member_methods_spec.rb +47 -0
- data/spec/lib/chatwork/client/message_methods_spec.rb +102 -0
- data/spec/lib/chatwork/client/my_status_methods_spec.rb +11 -0
- data/spec/lib/chatwork/client/my_task_methods_spec.rb +20 -0
- data/spec/lib/chatwork/client/room_methods_spec.rb +111 -0
- data/spec/lib/chatwork/client/task_methods_spec.rb +80 -0
- data/spec/lib/chatwork/client_spec.rb +8 -1
- data/spec/lib/chatwork/contacts_spec.rb +2 -2
- data/spec/lib/chatwork/{entity_methods_spec.rb → converter_spec.rb} +2 -2
- data/spec/lib/chatwork/file_spec.rb +2 -2
- data/spec/lib/chatwork/incoming_request_spec.rb +3 -3
- data/spec/lib/chatwork/invitation_link_spec.rb +4 -2
- data/spec/lib/chatwork/me_spec.rb +3 -21
- data/spec/lib/chatwork/member_spec.rb +2 -1
- data/spec/lib/chatwork/message_spec.rb +7 -7
- data/spec/lib/chatwork/my_status_spec.rb +1 -1
- data/spec/lib/chatwork/my_task_spec.rb +1 -0
- data/spec/lib/chatwork/{token_spec.rb → oauth_client/token_methods_spec.rb} +4 -7
- data/spec/lib/chatwork/oauth_client_spec.rb +7 -1
- data/spec/lib/chatwork/room_spec.rb +5 -2
- data/spec/lib/chatwork/task_spec.rb +3 -0
- data/spec/support/contexts/api_context.rb +4 -3
- data/spec/support/examples/a_chatwork_api.rb +22 -5
- data/spec/support/utils/raml_parser.rb +2 -3
- metadata +42 -8
- data/lib/chatwork/entity_methods.rb +0 -36
data/lib/chatwork/room.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module ChatWork
|
2
2
|
module Room
|
3
|
-
extend EntityMethods
|
4
|
-
|
5
3
|
# Get the list of all chats on your account
|
6
4
|
#
|
7
5
|
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms
|
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
|
@@ -27,8 +29,8 @@ module ChatWork
|
|
27
29
|
# "last_update_time": 1298905200
|
28
30
|
# }
|
29
31
|
# ]
|
30
|
-
def self.get
|
31
|
-
|
32
|
+
def self.get(&block)
|
33
|
+
ChatWork.client.get_rooms(&block)
|
32
34
|
end
|
33
35
|
|
34
36
|
# rubocop:disable Metrics/ParameterLists
|
@@ -50,6 +52,10 @@ module ChatWork
|
|
50
52
|
# @param link_code [String] link path (default. random string)
|
51
53
|
# @param link_need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
52
54
|
#
|
55
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
56
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
57
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
58
|
+
#
|
53
59
|
# @return [Hashie::Mash]
|
54
60
|
#
|
55
61
|
# @example response format
|
@@ -57,20 +63,19 @@ module ChatWork
|
|
57
63
|
# "room_id": 1234
|
58
64
|
# }
|
59
65
|
def self.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name:,
|
60
|
-
link: nil, link_code: nil, link_need_acceptance: nil)
|
61
|
-
|
66
|
+
link: nil, link_code: nil, link_need_acceptance: nil, &block)
|
67
|
+
ChatWork.client.create_room(
|
62
68
|
description: description,
|
63
69
|
icon_preset: icon_preset,
|
64
|
-
members_admin_ids:
|
70
|
+
members_admin_ids: members_admin_ids,
|
71
|
+
members_member_ids: members_member_ids,
|
72
|
+
members_readonly_ids: members_readonly_ids,
|
65
73
|
name: name,
|
66
|
-
link:
|
67
|
-
link_need_acceptance: boolean_to_integer(link_need_acceptance),
|
74
|
+
link: link,
|
68
75
|
link_code: link_code,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
_post("/rooms", params)
|
76
|
+
link_need_acceptance: link_need_acceptance,
|
77
|
+
&block
|
78
|
+
)
|
74
79
|
end
|
75
80
|
|
76
81
|
# rubocop:enable Metrics/ParameterLists
|
@@ -82,6 +87,10 @@ module ChatWork
|
|
82
87
|
#
|
83
88
|
# @param room_id [Integer]
|
84
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
|
+
#
|
85
94
|
# @return [Hashie::Mash]
|
86
95
|
#
|
87
96
|
# @example response format
|
@@ -101,8 +110,8 @@ module ChatWork
|
|
101
110
|
# "last_update_time": 1298905200,
|
102
111
|
# "description": "room description text"
|
103
112
|
# }
|
104
|
-
def self.find(room_id
|
105
|
-
|
113
|
+
def self.find(room_id:, &block)
|
114
|
+
ChatWork.client.find_room(room_id: room_id, &block)
|
106
115
|
end
|
107
116
|
|
108
117
|
# Change the title and icon type of the specified chat
|
@@ -116,14 +125,18 @@ module ChatWork
|
|
116
125
|
# study, security, star, idea, heart, magcup, beer, music, sports, travel)
|
117
126
|
# @param name [String] Title of the group chat.
|
118
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
|
+
#
|
119
132
|
# @return [Hashie::Mash]
|
120
133
|
#
|
121
134
|
# @example response format
|
122
135
|
# {
|
123
136
|
# "room_id": 1234
|
124
137
|
# }
|
125
|
-
def self.update(room_id:, description: nil, icon_preset: nil, name: nil)
|
126
|
-
|
138
|
+
def self.update(room_id:, description: nil, icon_preset: nil, name: nil, &block)
|
139
|
+
ChatWork.client.update_room(room_id: room_id, description: description, icon_preset: icon_preset, name: name, &block)
|
127
140
|
end
|
128
141
|
|
129
142
|
# Leave/Delete a group chat
|
@@ -133,8 +146,12 @@ module ChatWork
|
|
133
146
|
#
|
134
147
|
# @param room_id [Integer]
|
135
148
|
# @param action_type [String] leave from a room or delete a room (leave, delete)
|
136
|
-
|
137
|
-
|
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 self.destroy(room_id:, action_type:, &block)
|
154
|
+
ChatWork.client.destroy_room(room_id: room_id, action_type: action_type, &block)
|
138
155
|
end
|
139
156
|
end
|
140
157
|
end
|
data/lib/chatwork/task.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module ChatWork
|
2
2
|
module Task
|
3
|
-
extend EntityMethods
|
4
|
-
|
5
3
|
# Get the list of tasks associated with the specified chat
|
6
4
|
#
|
7
5
|
# (*This method returns up to 100 entries. We are planning to implement pagination to support larger number of data retrieval)
|
@@ -14,6 +12,10 @@ module ChatWork
|
|
14
12
|
# @param assigned_by_account_id [Integer] Account ID of the person who assigned task
|
15
13
|
# @param status [String] Task status (open, done)
|
16
14
|
#
|
15
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
16
|
+
# @yieldparam response_body [Array<Hashie::Mash>] response body
|
17
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
18
|
+
#
|
17
19
|
# @return [Array<Hashie::Mash>]
|
18
20
|
#
|
19
21
|
# @example response format
|
@@ -36,8 +38,8 @@ module ChatWork
|
|
36
38
|
# "status": "open"
|
37
39
|
# }
|
38
40
|
# ]
|
39
|
-
def self.get(room_id:, account_id:, assigned_by_account_id: nil, status: nil)
|
40
|
-
|
41
|
+
def self.get(room_id:, account_id:, assigned_by_account_id: nil, status: nil, &block)
|
42
|
+
ChatWork.client.get_tasks(room_id: room_id, account_id: account_id, assigned_by_account_id: assigned_by_account_id, status: status, &block)
|
41
43
|
end
|
42
44
|
|
43
45
|
# Add a new task to the chat
|
@@ -50,20 +52,18 @@ module ChatWork
|
|
50
52
|
# @param to_ids [Array<Integer>, String] Account ID of the person/people responsible to complete the task
|
51
53
|
# @param limit [Time, Integer] When the task is due
|
52
54
|
#
|
55
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
56
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
57
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
58
|
+
#
|
53
59
|
# @return [Hashie::Mash]
|
54
60
|
#
|
55
61
|
# @example response format
|
56
62
|
# {
|
57
63
|
# "task_ids": [123,124]
|
58
64
|
# }
|
59
|
-
def self.create(room_id:, body:, to_ids:, limit: nil)
|
60
|
-
|
61
|
-
body: body,
|
62
|
-
to_ids: Array(to_ids).join(","),
|
63
|
-
}
|
64
|
-
params[:limit] = limit.to_i if limit
|
65
|
-
|
66
|
-
_post("/rooms/#{room_id}/tasks", params)
|
65
|
+
def self.create(room_id:, body:, to_ids:, limit: nil, &block)
|
66
|
+
ChatWork.client.create_task(room_id: room_id, body: body, to_ids: to_ids, limit: limit, &block)
|
67
67
|
end
|
68
68
|
|
69
69
|
# Get information about the specified task
|
@@ -74,6 +74,10 @@ module ChatWork
|
|
74
74
|
# @param room_id [Integer]
|
75
75
|
# @param task_id [Integer]
|
76
76
|
#
|
77
|
+
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
|
78
|
+
# @yieldparam response_body [Hashie::Mash] response body
|
79
|
+
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
|
80
|
+
#
|
77
81
|
# @return [Hashie::Mash]
|
78
82
|
#
|
79
83
|
# @example response format
|
@@ -94,8 +98,8 @@ module ChatWork
|
|
94
98
|
# "limit_time": 1384354799,
|
95
99
|
# "status": "open"
|
96
100
|
# }
|
97
|
-
def self.find(room_id:, task_id
|
98
|
-
|
101
|
+
def self.find(room_id:, task_id:, &block)
|
102
|
+
ChatWork.client.find_task(room_id: room_id, task_id: task_id, &block)
|
99
103
|
end
|
100
104
|
end
|
101
105
|
end
|
data/lib/chatwork/token.rb
CHANGED
@@ -15,13 +15,7 @@ module ChatWork
|
|
15
15
|
# "scope" => "users.all:read rooms.all:read_write contacts.all:read_write",
|
16
16
|
# }
|
17
17
|
def self.refresh_access_token(refresh_token, scope = [])
|
18
|
-
|
19
|
-
grant_type: "refresh_token",
|
20
|
-
refresh_token: refresh_token,
|
21
|
-
}
|
22
|
-
params[:scope] = scope.join(" ") unless scope.empty?
|
23
|
-
|
24
|
-
ChatWork.oauth_client.post("/token", params)
|
18
|
+
ChatWork.oauth_client.refresh_access_token(refresh_token, scope)
|
25
19
|
end
|
26
20
|
end
|
27
21
|
end
|
data/lib/chatwork/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
describe ChatWork::Client::ContactsMethods do
|
2
|
+
describe "#get_contacts", type: :api do
|
3
|
+
subject { client.get_contacts(&block) }
|
4
|
+
|
5
|
+
before do
|
6
|
+
stub_chatwork_request(:get, "/contacts")
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like :a_chatwork_api, :get, "/contacts"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
describe ChatWork::Client::FileMethods do
|
2
|
+
describe "#get_files", type: :api do
|
3
|
+
subject { client.get_files(room_id: room_id, account_id: account_id, &block) }
|
4
|
+
|
5
|
+
before do
|
6
|
+
stub_chatwork_request(:get, "/rooms/#{room_id}/files", "/rooms/{room_id}/files")
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:room_id) { 123 }
|
10
|
+
let(:account_id) { 101 }
|
11
|
+
|
12
|
+
it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files"
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#find_file", type: :api do
|
16
|
+
subject { client.find_file(room_id: room_id, file_id: file_id, create_download_url: create_download_url, &block) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
stub_chatwork_request(:get, "/rooms/#{room_id}/files/#{file_id}", "/rooms/{room_id}/files/{file_id}")
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:room_id) { 123 }
|
23
|
+
let(:file_id) { 101 }
|
24
|
+
|
25
|
+
context "when force is Integer" do
|
26
|
+
let(:create_download_url) { 1 }
|
27
|
+
|
28
|
+
it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files/{file_id}"
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when force is boolean" do
|
32
|
+
let(:create_download_url) { true }
|
33
|
+
|
34
|
+
it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files/{file_id}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe ChatWork::Client::IncomingRequestMethods do
|
2
|
+
describe "#get_incoming_requests", type: :api do
|
3
|
+
subject { client.get_incoming_requests(&block) }
|
4
|
+
|
5
|
+
before do
|
6
|
+
stub_chatwork_request(:get, "/incoming_requests")
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like :a_chatwork_api, :get, "/incoming_requests"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#update_incoming_request", type: :api do
|
13
|
+
subject { client.update_incoming_request(request_id: request_id, &block) }
|
14
|
+
|
15
|
+
let(:request_id) { 123 }
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub_chatwork_request(:put, "/incoming_requests/#{request_id}", "/incoming_requests/{request_id}")
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like :a_chatwork_api, :put, "/incoming_requests/{request_id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#destroy_incoming_request", type: :api do
|
25
|
+
subject { client.destroy_incoming_request(request_id: request_id, &block) }
|
26
|
+
|
27
|
+
let(:request_id) { 123 }
|
28
|
+
|
29
|
+
before do
|
30
|
+
stub_chatwork_request(:delete, "/incoming_requests/#{request_id}", "/incoming_requests/{request_id}", 204)
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like :a_chatwork_api, :delete, "/incoming_requests/{request_id}", 204
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
describe ChatWork::Client::InvitationLinkMethods do
|
2
|
+
describe "#get_invitation_link", type: :api do
|
3
|
+
subject { client.get_invitation_link(room_id: room_id, &block) }
|
4
|
+
|
5
|
+
let(:room_id) { 123 }
|
6
|
+
|
7
|
+
before do
|
8
|
+
stub_chatwork_request(:get, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
9
|
+
end
|
10
|
+
|
11
|
+
it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/link"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#create_invitation_link", type: :api do
|
15
|
+
subject do
|
16
|
+
client.create_invitation_link(
|
17
|
+
room_id: room_id,
|
18
|
+
code: code,
|
19
|
+
description: description,
|
20
|
+
need_acceptance: need_acceptance,
|
21
|
+
&block
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:room_id) { 123 }
|
26
|
+
let(:code) { "unique-link-name" }
|
27
|
+
let(:description) { "This is a public room for topic A." }
|
28
|
+
let(:need_acceptance) { true }
|
29
|
+
|
30
|
+
before do
|
31
|
+
stub_chatwork_request(:post, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
32
|
+
end
|
33
|
+
|
34
|
+
it_behaves_like :a_chatwork_api, :post, "/rooms/{room_id}/link"
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#update_invitation_link", type: :api do
|
38
|
+
subject do
|
39
|
+
client.update_invitation_link(
|
40
|
+
room_id: room_id,
|
41
|
+
code: code,
|
42
|
+
description: description,
|
43
|
+
need_acceptance: need_acceptance,
|
44
|
+
&block
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:room_id) { 123 }
|
49
|
+
let(:code) { "another_link_name" }
|
50
|
+
let(:description) { "Public room for everybody" }
|
51
|
+
let(:need_acceptance) { false }
|
52
|
+
|
53
|
+
before do
|
54
|
+
stub_chatwork_request(:put, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
55
|
+
end
|
56
|
+
|
57
|
+
it_behaves_like :a_chatwork_api, :put, "/rooms/{room_id}/link"
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#destroy_invitation_link", type: :api do
|
61
|
+
subject { client.destroy_invitation_link(room_id: room_id, &block) }
|
62
|
+
|
63
|
+
let(:room_id) { 123 }
|
64
|
+
|
65
|
+
before do
|
66
|
+
stub_chatwork_request(:delete, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
67
|
+
end
|
68
|
+
|
69
|
+
it_behaves_like :a_chatwork_api, :delete, "/rooms/{room_id}/link"
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe ChatWork::Client::MeMethods do
|
2
|
+
describe "get_me", type: :api do
|
3
|
+
subject { client.get_me(&block) }
|
4
|
+
|
5
|
+
before do
|
6
|
+
stub_chatwork_request(:get, "/me")
|
7
|
+
end
|
8
|
+
|
9
|
+
it_behaves_like :a_chatwork_api, :get, "/me"
|
10
|
+
|
11
|
+
context "when unauthorized" do
|
12
|
+
before do
|
13
|
+
stub_chatwork_request(:get, "/me", "/me", 401)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:block) { nil }
|
17
|
+
|
18
|
+
it { expect { subject }.to raise_error(ChatWork::APIError, "Invalid API token") }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe ChatWork::Client::MemberMethods do
|
2
|
+
describe "#get_members", type: :api do
|
3
|
+
subject { client.get_members(room_id: room_id, &block) }
|
4
|
+
|
5
|
+
let(:room_id) { 123 }
|
6
|
+
|
7
|
+
before do
|
8
|
+
stub_chatwork_request(:get, "/rooms/#{room_id}/members", "/rooms/{room_id}/members")
|
9
|
+
end
|
10
|
+
|
11
|
+
it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/members"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#update_all_members", type: :api do
|
15
|
+
subject do
|
16
|
+
client.update_all_members(
|
17
|
+
room_id: room_id,
|
18
|
+
members_admin_ids: members_admin_ids,
|
19
|
+
members_member_ids: members_member_ids,
|
20
|
+
members_readonly_ids: members_readonly_ids,
|
21
|
+
&block
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:room_id) { 123 }
|
26
|
+
|
27
|
+
before do
|
28
|
+
stub_chatwork_request(:put, "/rooms/#{room_id}/members", "/rooms/{room_id}/members")
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with String" do
|
32
|
+
let(:members_admin_ids) { "123,542,1001" }
|
33
|
+
let(:members_member_ids) { "21,344" }
|
34
|
+
let(:members_readonly_ids) { "15,103" }
|
35
|
+
|
36
|
+
it_behaves_like :a_chatwork_api, :put, "/rooms/{room_id}/members"
|
37
|
+
end
|
38
|
+
|
39
|
+
context "with Array" do
|
40
|
+
let(:members_admin_ids) { [123, 542, 1001] }
|
41
|
+
let(:members_member_ids) { [21, 344] }
|
42
|
+
let(:members_readonly_ids) { [15, 103] }
|
43
|
+
|
44
|
+
it_behaves_like :a_chatwork_api, :put, "/rooms/{room_id}/members"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|