-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathinvitation_link.rb
102 lines (99 loc) · 4.34 KB
/
invitation_link.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
module ChatWork
module InvitationLink
# Get invitation link
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-link
# @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 [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
# {
# "public": true,
# "url": "https://example.chatwork.com/g/randomcode42",
# "need_acceptance": true,
# "description": "Link description text"
# }
def self.get(room_id:, &block)
ChatWork.client.get_invitation_link(room_id: room_id, &block)
end
# Create invitation link
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-link
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param room_id [Integer]
# @param code [String] link path (default. random string)
# @param description [String] description of link page
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
#
# @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
# {
# "public": true,
# "url": "https://example.chatwork.com/g/unique-link-name",
# "need_acceptance": true,
# "description": "This is a public room for topic A."
# }
def self.create(room_id:, code: nil, description: nil, need_acceptance: nil, &block)
ChatWork.client.create_invitation_link(room_id: room_id, code: code, description: description, need_acceptance: need_acceptance, &block)
end
# Update invitation link
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-link
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
#
# @param room_id [Integer]
# @param code [String] link path (default. random string)
# @param description [String] description of link page
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
#
# @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
# {
# "public": true,
# "url": "https://example.chatwork.com/g/another_link_name",
# "need_acceptance": false,
# "description": "Public room for everybody"
# }
def self.update(room_id:, code: nil, description: nil, need_acceptance: nil, &block)
ChatWork.client.update_invitation_link(room_id: room_id, code: code, description: description, need_acceptance: need_acceptance, &block)
end
# Delete invitation link
#
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#DELETE-rooms-room_id-link
# @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 [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
# {
# "public": false
# }
def self.destroy(room_id:, &block)
ChatWork.client.destroy_invitation_link(room_id: room_id, &block)
end
end
end