chatwork 0.6.2 → 0.7.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 +7 -1
- data/lib/chatwork.rb +1 -0
- data/lib/chatwork/invitation_link.rb +98 -0
- data/lib/chatwork/room.rb +12 -5
- data/lib/chatwork/version.rb +1 -1
- data/spec/lib/chatwork/invitation_link_spec.rb +69 -0
- data/spec/lib/chatwork/room_spec.rb +9 -3
- data/spec/support/utils/raml_parser.rb +26 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f74e386e6cd2bfdb296f318244c848833efe5281661a70fd5f2b25997e5bbcc
|
4
|
+
data.tar.gz: ec96eec7324daf0413443dbae362119ed08191b89627269fdc5a757313a829c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cade7059d99ac62bb9245a8f0089007605fb0f29f887c4bfa7947165180649388cfc1466dd760491023feb523584fedc0a4288d5d4f4b252d5e5e63c81374ebd
|
7
|
+
data.tar.gz: 0e7b226006c9a84f650139ca991b2eebfda2576f6cad148da5b8fde20deceba3d00fd07de10d18588b2913c09384661e05d65e4b5149b2bfb886ac956a9aa651
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
## Unreleased
|
3
|
-
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.
|
3
|
+
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.7.0...master)
|
4
|
+
|
5
|
+
## v0.7.0
|
6
|
+
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.6.2...v0.7.0)
|
7
|
+
|
8
|
+
* Support Invitation Link API
|
9
|
+
* https://github.com/asonas/chatwork-ruby/pull/46
|
4
10
|
|
5
11
|
## v0.6.2
|
6
12
|
[Full Changelog](https://github.com/asonas/chatwork-ruby/compare/v0.6.1...v0.6.2)
|
data/lib/chatwork.rb
CHANGED
@@ -12,6 +12,7 @@ module ChatWork
|
|
12
12
|
autoload :EntityMethods, "chatwork/entity_methods"
|
13
13
|
autoload :File, "chatwork/file"
|
14
14
|
autoload :IncomingRequest, "chatwork/incoming_request"
|
15
|
+
autoload :InvitationLink, "chatwork/invitation_link"
|
15
16
|
autoload :Me, "chatwork/me"
|
16
17
|
autoload :Member, "chatwork/member"
|
17
18
|
autoload :Message, "chatwork/message"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module ChatWork
|
2
|
+
module InvitationLink
|
3
|
+
extend EntityMethods
|
4
|
+
|
5
|
+
# Get invitation link
|
6
|
+
#
|
7
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#GET-rooms-room_id-link
|
8
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
9
|
+
#
|
10
|
+
# @param room_id [Integer]
|
11
|
+
#
|
12
|
+
# @return [Hashie::Mash]
|
13
|
+
#
|
14
|
+
# @example response format
|
15
|
+
# {
|
16
|
+
# "public": true,
|
17
|
+
# "url": "https://example.chatwork.com/g/randomcode42",
|
18
|
+
# "need_acceptance": true,
|
19
|
+
# "description": "Link description text"
|
20
|
+
# }
|
21
|
+
def self.get(room_id:)
|
22
|
+
_get("/rooms/#{room_id}/link")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create invitation link
|
26
|
+
#
|
27
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-link
|
28
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
29
|
+
#
|
30
|
+
# @param room_id [Integer]
|
31
|
+
# @param code [String] link path (default. random string)
|
32
|
+
# @param description [String] description of link page
|
33
|
+
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
34
|
+
#
|
35
|
+
# @return [Hashie::Mash]
|
36
|
+
#
|
37
|
+
# @example response format
|
38
|
+
# {
|
39
|
+
# "public": true,
|
40
|
+
# "url": "https://example.chatwork.com/g/unique-link-name",
|
41
|
+
# "need_acceptance": true,
|
42
|
+
# "description": "This is a public room for topic A."
|
43
|
+
# }
|
44
|
+
def self.create(room_id:, code: nil, description: nil, need_acceptance: nil)
|
45
|
+
params = {
|
46
|
+
code: code,
|
47
|
+
description: description,
|
48
|
+
need_acceptance: boolean_to_integer(need_acceptance),
|
49
|
+
}
|
50
|
+
_post("/rooms/#{room_id}/link", params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Update invitation link
|
54
|
+
#
|
55
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#PUT-rooms-room_id-link
|
56
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
57
|
+
#
|
58
|
+
# @param room_id [Integer]
|
59
|
+
# @param code [String] link path (default. random string)
|
60
|
+
# @param description [String] description of link page
|
61
|
+
# @param need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
62
|
+
#
|
63
|
+
# @return [Hashie::Mash]
|
64
|
+
#
|
65
|
+
# @example response format
|
66
|
+
# {
|
67
|
+
# "public": true,
|
68
|
+
# "url": "https://example.chatwork.com/g/another_link_name",
|
69
|
+
# "need_acceptance": false,
|
70
|
+
# "description": "Public room for everybody"
|
71
|
+
# }
|
72
|
+
def self.update(room_id:, code: nil, description: nil, need_acceptance: nil)
|
73
|
+
params = {
|
74
|
+
code: code,
|
75
|
+
description: description,
|
76
|
+
need_acceptance: boolean_to_integer(need_acceptance),
|
77
|
+
}
|
78
|
+
_put("/rooms/#{room_id}/link", params)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Delete invitation link
|
82
|
+
#
|
83
|
+
# @see http://developer.chatwork.com/ja/endpoint_rooms.html#DELETE-rooms-room_id-link
|
84
|
+
# @see http://download.chatwork.com/ChatWork_API_Documentation.pdf
|
85
|
+
#
|
86
|
+
# @param room_id [Integer]
|
87
|
+
#
|
88
|
+
# @return [Hashie::Mash]
|
89
|
+
#
|
90
|
+
# @example response format
|
91
|
+
# {
|
92
|
+
# "public": false
|
93
|
+
# }
|
94
|
+
def self.destroy(room_id:)
|
95
|
+
_delete("/rooms/#{room_id}/link")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/chatwork/room.rb
CHANGED
@@ -46,6 +46,9 @@ module ChatWork
|
|
46
46
|
# @param members_member_ids [Array<Integer>, String] List of user IDs who will be given member permission for the group chat.
|
47
47
|
# @param members_readonly_ids [Array<Integer>, String] List of user IDs who will be given read-only permission for the group chat.
|
48
48
|
# @param name [String] Title of the group chat.
|
49
|
+
# @param link [Boolean] whether create invitation link
|
50
|
+
# @param link_code [String] link path (default. random string)
|
51
|
+
# @param link_need_acceptance [Boolean] Approval necessity. Whether participation requires administrator approval.
|
49
52
|
#
|
50
53
|
# @return [Hashie::Mash]
|
51
54
|
#
|
@@ -53,12 +56,16 @@ module ChatWork
|
|
53
56
|
# {
|
54
57
|
# "room_id": 1234
|
55
58
|
# }
|
56
|
-
def self.create(description: nil, icon_preset: nil, members_admin_ids:, members_member_ids: nil, members_readonly_ids: nil, name
|
59
|
+
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)
|
57
61
|
params = {
|
58
|
-
description:
|
59
|
-
icon_preset:
|
60
|
-
members_admin_ids:
|
61
|
-
name:
|
62
|
+
description: description,
|
63
|
+
icon_preset: icon_preset,
|
64
|
+
members_admin_ids: Array(members_admin_ids).join(","),
|
65
|
+
name: name,
|
66
|
+
link: boolean_to_integer(link),
|
67
|
+
link_need_acceptance: boolean_to_integer(link_need_acceptance),
|
68
|
+
link_code: link_code,
|
62
69
|
}
|
63
70
|
params[:members_member_ids] = Array(members_member_ids).join(",") if members_member_ids
|
64
71
|
params[:members_readonly_ids] = Array(members_readonly_ids).join(",") if members_readonly_ids
|
data/lib/chatwork/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
describe ChatWork::InvitationLink do
|
2
|
+
describe ".get", type: :api do
|
3
|
+
subject { ChatWork::InvitationLink.get(room_id: room_id) }
|
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", type: :api do
|
15
|
+
subject do
|
16
|
+
ChatWork::InvitationLink.create(
|
17
|
+
room_id: room_id,
|
18
|
+
code: code,
|
19
|
+
description: description,
|
20
|
+
need_acceptance: need_acceptance,
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:room_id) { 123 }
|
25
|
+
let(:code) { "unique-link-name" }
|
26
|
+
let(:description) { "This is a public room for topic A." }
|
27
|
+
let(:need_acceptance) { true }
|
28
|
+
|
29
|
+
before do
|
30
|
+
stub_chatwork_request(:post, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
31
|
+
end
|
32
|
+
|
33
|
+
it_behaves_like :a_chatwork_api, :post, "/rooms/{room_id}/link"
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".update", type: :api do
|
37
|
+
subject do
|
38
|
+
ChatWork::InvitationLink.update(
|
39
|
+
room_id: room_id,
|
40
|
+
code: code,
|
41
|
+
description: description,
|
42
|
+
need_acceptance: need_acceptance,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:room_id) { 123 }
|
47
|
+
let(:code) { "another_link_name" }
|
48
|
+
let(:description) { "Public room for everybody" }
|
49
|
+
let(:need_acceptance) { false }
|
50
|
+
|
51
|
+
before do
|
52
|
+
stub_chatwork_request(:put, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
53
|
+
end
|
54
|
+
|
55
|
+
it_behaves_like :a_chatwork_api, :put, "/rooms/{room_id}/link"
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".destroy", type: :api do
|
59
|
+
subject { ChatWork::InvitationLink.destroy(room_id: room_id) }
|
60
|
+
|
61
|
+
let(:room_id) { 123 }
|
62
|
+
|
63
|
+
before do
|
64
|
+
stub_chatwork_request(:delete, "/rooms/#{room_id}/link", "/rooms/{room_id}/link")
|
65
|
+
end
|
66
|
+
|
67
|
+
it_behaves_like :a_chatwork_api, :delete, "/rooms/{room_id}/link"
|
68
|
+
end
|
69
|
+
end
|
@@ -20,12 +20,18 @@ describe ChatWork::Room do
|
|
20
20
|
members_member_ids: members_member_ids,
|
21
21
|
members_readonly_ids: members_readonly_ids,
|
22
22
|
name: name,
|
23
|
+
link: link,
|
24
|
+
link_code: link_code,
|
25
|
+
link_need_acceptance: link_need_acceptance,
|
23
26
|
)
|
24
27
|
end
|
25
28
|
|
26
|
-
let(:description)
|
27
|
-
let(:icon_preset)
|
28
|
-
let(:name)
|
29
|
+
let(:description) { "group chat description" }
|
30
|
+
let(:icon_preset) { "meeting" }
|
31
|
+
let(:name) { "Website renewal project" }
|
32
|
+
let(:link) { false }
|
33
|
+
let(:link_need_acceptance) { true }
|
34
|
+
let(:link_code) { nil }
|
29
35
|
|
30
36
|
before do
|
31
37
|
stub_chatwork_request(:post, "/rooms")
|
@@ -33,7 +33,7 @@ module RamlParser
|
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.find_query_parameter_example(verb, path)
|
36
|
+
def self.find_query_parameter_example(verb, path) # rubocop:disable Metrics/MethodLength
|
37
37
|
resource = find_resource(verb, path)
|
38
38
|
return {} unless resource
|
39
39
|
|
@@ -41,7 +41,8 @@ module RamlParser
|
|
41
41
|
|
42
42
|
if resource["queryParameters"]
|
43
43
|
resource["queryParameters"].each do |name, value|
|
44
|
-
|
44
|
+
example = find_example(value)
|
45
|
+
parameter_example[name] = example if example
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -52,7 +53,8 @@ module RamlParser
|
|
52
53
|
next unless trait["queryParameters"]
|
53
54
|
|
54
55
|
trait["queryParameters"].each do |name, value|
|
55
|
-
|
56
|
+
example = find_example(value)
|
57
|
+
parameter_example[name] = example if example
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -77,4 +79,25 @@ module RamlParser
|
|
77
79
|
response_json
|
78
80
|
end
|
79
81
|
private_class_method :parse_response
|
82
|
+
|
83
|
+
def self.find_example(value)
|
84
|
+
example =
|
85
|
+
if value.has_key?("example")
|
86
|
+
value["example"]
|
87
|
+
elsif value.has_key?("default")
|
88
|
+
value["default"]
|
89
|
+
end
|
90
|
+
|
91
|
+
return nil if example.nil?
|
92
|
+
|
93
|
+
case example
|
94
|
+
when true
|
95
|
+
1
|
96
|
+
when false
|
97
|
+
0
|
98
|
+
else
|
99
|
+
example
|
100
|
+
end
|
101
|
+
end
|
102
|
+
private_class_method :find_example
|
80
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chatwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asonas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/chatwork/entity_methods.rb
|
280
280
|
- lib/chatwork/file.rb
|
281
281
|
- lib/chatwork/incoming_request.rb
|
282
|
+
- lib/chatwork/invitation_link.rb
|
282
283
|
- lib/chatwork/me.rb
|
283
284
|
- lib/chatwork/member.rb
|
284
285
|
- lib/chatwork/message.rb
|
@@ -295,6 +296,7 @@ files:
|
|
295
296
|
- spec/lib/chatwork/entity_methods_spec.rb
|
296
297
|
- spec/lib/chatwork/file_spec.rb
|
297
298
|
- spec/lib/chatwork/incoming_request_spec.rb
|
299
|
+
- spec/lib/chatwork/invitation_link_spec.rb
|
298
300
|
- spec/lib/chatwork/me_spec.rb
|
299
301
|
- spec/lib/chatwork/member_spec.rb
|
300
302
|
- spec/lib/chatwork/message_spec.rb
|
@@ -342,6 +344,7 @@ test_files:
|
|
342
344
|
- spec/lib/chatwork/entity_methods_spec.rb
|
343
345
|
- spec/lib/chatwork/file_spec.rb
|
344
346
|
- spec/lib/chatwork/incoming_request_spec.rb
|
347
|
+
- spec/lib/chatwork/invitation_link_spec.rb
|
345
348
|
- spec/lib/chatwork/me_spec.rb
|
346
349
|
- spec/lib/chatwork/member_spec.rb
|
347
350
|
- spec/lib/chatwork/message_spec.rb
|