rocketchat 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_chat/error.rb +1 -0
- data/lib/rocket_chat/gem_version.rb +1 -1
- data/lib/rocket_chat/messages/group.rb +6 -12
- data/lib/rocket_chat/messages/room.rb +38 -12
- data/lib/rocket_chat/request_helper.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92064005eb022f8630c18a093696fc5058cde945
|
4
|
+
data.tar.gz: 8106bebe9e04e28e06889d283876e0e00194c651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2de3192406d8a89a6b7c0cf808be8af72ba7e5a27013f3e4850987bd3858649926beb4dfe037a45ec59d0990d7a757480cfe432a469dec3c27a0a2476d6400c
|
7
|
+
data.tar.gz: dcf80cf8c56457594c613a249affdddcf29f3a77459b548db3cae7c13d549eabde4d59c487e13d901dd3280690a95c9e065e029137f89c2131cc9aa9ffd9f463
|
data/lib/rocket_chat/error.rb
CHANGED
@@ -13,15 +13,12 @@ module RocketChat
|
|
13
13
|
# @return [Boolean]
|
14
14
|
# @raise [HTTPError, StatusError]
|
15
15
|
#
|
16
|
-
def add_leader(room_id: nil, user_id: nil)
|
16
|
+
def add_leader(room_id: nil, name: nil, user_id: nil, username: nil)
|
17
17
|
session.request_json(
|
18
18
|
self.class.api_path('addLeader'),
|
19
19
|
method: :post,
|
20
|
-
body:
|
21
|
-
|
22
|
-
userId: user_id
|
23
|
-
},
|
24
|
-
upstreamed_errors: ['error-room-not-found']
|
20
|
+
body: room_params(room_id, name)
|
21
|
+
.merge(user_params(user_id, username))
|
25
22
|
)['success']
|
26
23
|
end
|
27
24
|
|
@@ -32,15 +29,12 @@ module RocketChat
|
|
32
29
|
# @return [Boolean]
|
33
30
|
# @raise [HTTPError, StatusError]
|
34
31
|
#
|
35
|
-
def remove_leader(room_id: nil, user_id: nil)
|
32
|
+
def remove_leader(room_id: nil, name: nil, user_id: nil, username: nil)
|
36
33
|
session.request_json(
|
37
34
|
self.class.api_path('removeLeader'),
|
38
35
|
method: :post,
|
39
|
-
body:
|
40
|
-
|
41
|
-
userId: user_id
|
42
|
-
},
|
43
|
-
upstreamed_errors: ['error-room-not-found']
|
36
|
+
body: room_params(room_id, name)
|
37
|
+
.merge(user_params(user_id, username))
|
44
38
|
)['success']
|
45
39
|
end
|
46
40
|
|
@@ -67,15 +67,12 @@ module RocketChat
|
|
67
67
|
# @return [Boolean]
|
68
68
|
# @raise [HTTPError, StatusError]
|
69
69
|
#
|
70
|
-
def add_owner(room_id: nil, user_id: nil)
|
70
|
+
def add_owner(room_id: nil, name: nil, user_id: nil, username: nil)
|
71
71
|
session.request_json(
|
72
72
|
self.class.api_path('addOwner'),
|
73
73
|
method: :post,
|
74
|
-
body:
|
75
|
-
|
76
|
-
userId: user_id
|
77
|
-
},
|
78
|
-
upstreamed_errors: ['error-room-not-found']
|
74
|
+
body: room_params(room_id, name)
|
75
|
+
.merge(user_params(user_id, username))
|
79
76
|
)['success']
|
80
77
|
end
|
81
78
|
|
@@ -86,15 +83,44 @@ module RocketChat
|
|
86
83
|
# @return [Boolean]
|
87
84
|
# @raise [HTTPError, StatusError]
|
88
85
|
#
|
89
|
-
def remove_owner(room_id: nil, user_id: nil)
|
86
|
+
def remove_owner(room_id: nil, name: nil, user_id: nil, username: nil)
|
90
87
|
session.request_json(
|
91
88
|
self.class.api_path('removeOwner'),
|
92
89
|
method: :post,
|
93
|
-
body:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
body: room_params(room_id, name)
|
91
|
+
.merge(user_params(user_id, username))
|
92
|
+
)['success']
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# *.add_moderator REST API
|
97
|
+
# @param [String] room_id Rocket.Chat room id
|
98
|
+
# @param [String] user_id Rocket.Chat user id
|
99
|
+
# @return [Boolean]
|
100
|
+
# @raise [HTTPError, StatusError]
|
101
|
+
#
|
102
|
+
def add_moderator(room_id: nil, name: nil, user_id: nil, username: nil)
|
103
|
+
session.request_json(
|
104
|
+
self.class.api_path('addModerator'),
|
105
|
+
method: :post,
|
106
|
+
body: room_params(room_id, name)
|
107
|
+
.merge(user_params(user_id, username))
|
108
|
+
)['success']
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# *.remove_moderator REST API
|
113
|
+
# @param [String] room_id Rocket.Chat room id
|
114
|
+
# @param [String] user_id Rocket.Chat user id
|
115
|
+
# @return [Boolean]
|
116
|
+
# @raise [HTTPError, StatusError]
|
117
|
+
#
|
118
|
+
def remove_moderator(room_id: nil, name: nil, user_id: nil, username: nil)
|
119
|
+
session.request_json(
|
120
|
+
self.class.api_path('removeModerator'),
|
121
|
+
method: :post,
|
122
|
+
body: room_params(room_id, name)
|
123
|
+
.merge(user_params(user_id, username))
|
98
124
|
)['success']
|
99
125
|
end
|
100
126
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'openssl'
|
3
|
+
require 'net/http'
|
3
4
|
|
4
5
|
module RocketChat
|
5
6
|
#
|
@@ -28,7 +29,7 @@ module RocketChat
|
|
28
29
|
response = request path, options
|
29
30
|
check_response response, fail_unless_ok
|
30
31
|
|
31
|
-
response_json =
|
32
|
+
response_json = parse_response(response.body)
|
32
33
|
options[:debug].puts("Response: #{response_json.inspect}") if options[:debug]
|
33
34
|
check_response_json response_json, upstreamed_errors
|
34
35
|
|
@@ -47,8 +48,14 @@ module RocketChat
|
|
47
48
|
|
48
49
|
private
|
49
50
|
|
51
|
+
def parse_response(response)
|
52
|
+
JSON.parse(response)
|
53
|
+
rescue JSON::ParserError
|
54
|
+
raise RocketChat::JsonParseError, "RocketChat response parse error: #{response}"
|
55
|
+
end
|
56
|
+
|
50
57
|
def check_response(response, fail_unless_ok)
|
51
|
-
return
|
58
|
+
return if response.is_a?(Net::HTTPOK) || !(fail_unless_ok || response.is_a?(Net::HTTPServerError))
|
52
59
|
raise RocketChat::HTTPError, "Invalid http response code: #{response.code}"
|
53
60
|
end
|
54
61
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- int512
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|