-
Notifications
You must be signed in to change notification settings - Fork 27
/
member.rb
66 lines (65 loc) · 2.83 KB
/
member.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module ChatWork
module Member
# Get the list of all chat members associated with the specified chat
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-members
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param room_id [Integer]
#
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
# @yieldparam response_body [Array<Hashie::Mash>] response body
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
#
# @return [Array<Hashie::Mash>]
#
# @example response format
# [
# {
# "account_id": 123,
# "role": "member",
# "name": "John Smith",
# "chatwork_id": "tarochatworkid",
# "organization_id": 101,
# "organization_name": "Hello Company",
# "department": "Marketing",
# "avatar_image_url": "https://example.com/abc.png"
# }
# ]
def self.get(room_id:, &block)
ChatWork.client.get_members(room_id: room_id, &block)
end
# Change associated members of group chat at once
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-members
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param room_id [Integer]
# @param members_admin_ids [Array<Integer>, String] List of user IDs who will be given administrator permission for the group chat.
# At least one user must be specified as an administrator.
# @param members_member_ids [Array<Integer>, String] List of user IDs who will be given member permission for the group chat.
# @param members_readonly_ids [Array<Integer>, String] List of user IDs who will be given read-only permission for the group chat.
#
# @yield [response_body, response_header] if block was given, return response body and response header through block arguments
# @yieldparam response_body [Hashie::Mash] response body
# @yieldparam response_header [Hash<String, String>] response header (e.g. X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
#
# @return [Hashie::Mash]
#
# @example response format
# {
# "admin": [123, 542, 1001],
# "member": [10, 103],
# "readonly": [6, 11]
# }
def self.update_all(room_id:, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, &block)
ChatWork.client.update_all_members(
room_id: room_id,
members_admin_ids: members_admin_ids,
members_member_ids: members_member_ids,
members_readonly_ids: members_readonly_ids,
&block
)
end
end
end