rocketchat 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/rocket_chat/gem_version.rb +1 -1
- data/lib/rocket_chat/messages/user.rb +32 -1
- data/lib/rocket_chat/request_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63395cd09bc2b53e342ce3d90fac28b2891d6021
|
4
|
+
data.tar.gz: 2be643107b5c947a9d775b208ba1fdeca8ac8d7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49ff8a992f56000de70631349a03b86d2ecc2b5002b2d430d59fb24ef08176406c40afba5ef1d32a0dc27306cc63f114f54f035b7c4083db572f9c66f3f8b98b
|
7
|
+
data.tar.gz: a9d75b6c61ccdd46f65241b37484f90a95f90ac9df1f757360ad59718180d7aa5486944c91c005a353099f1f2b53df012e34b814ad7781973c69d7e7db76c1a1
|
data/README.md
CHANGED
@@ -49,10 +49,12 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
49
49
|
|
50
50
|
#### Users
|
51
51
|
* [/api/v1/users.create](docs/users.md#userscreate)
|
52
|
+
* [/api/v1/users.createToken](docs/users.md#userscreatetoken)
|
52
53
|
* [/api/v1/users.delete](docs/users.md#usersdelete)
|
53
54
|
* [/api/v1/users.getPresence](docs/users.md#usersgetpresence)
|
54
55
|
* [/api/v1/users.info](docs/users.md#usersinfo)
|
55
56
|
* [/api/v1/users.list](docs/users.md#userslist)
|
57
|
+
* [/api/v1/users.resetAvatar](docs/users.md#usersresetavatar)
|
56
58
|
* [/api/v1/users.setAvatar](docs/users.md#userssetavatar)
|
57
59
|
* [/api/v1/users.update](docs/users.md#usersupdate)
|
58
60
|
|
@@ -85,6 +87,16 @@ session = rocket_server.login('username', 'password')
|
|
85
87
|
session.logout
|
86
88
|
```
|
87
89
|
|
90
|
+
#### debugging
|
91
|
+
To debug the communications between the gem and Rocket.Chat, there is a debug option.
|
92
|
+
It accepts a stream for logging.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
require 'rocketchat'
|
96
|
+
|
97
|
+
rocket_server = RocketChat::Server.new('http://your.server.address/', debug: $stderr)
|
98
|
+
```
|
99
|
+
|
88
100
|
|
89
101
|
For details of specific APIs:
|
90
102
|
|
@@ -3,7 +3,7 @@ module RocketChat
|
|
3
3
|
#
|
4
4
|
# Rocket.Chat User messages
|
5
5
|
#
|
6
|
-
class User
|
6
|
+
class User # rubocop:disable Metrics/ClassLength
|
7
7
|
include ListSupport
|
8
8
|
|
9
9
|
#
|
@@ -37,6 +37,22 @@ module RocketChat
|
|
37
37
|
RocketChat::User.new response['user']
|
38
38
|
end
|
39
39
|
|
40
|
+
#
|
41
|
+
# users.createToken REST API
|
42
|
+
# @param [String] user_id Rocket.Chat user id
|
43
|
+
# @param [String] username Username
|
44
|
+
# @return [RocketChat::Token]
|
45
|
+
# @raise [HTTPError, StatusError]
|
46
|
+
#
|
47
|
+
def create_token(user_id: nil, username: nil)
|
48
|
+
response = session.request_json(
|
49
|
+
'/api/v1/users.createToken',
|
50
|
+
method: :post,
|
51
|
+
body: user_params(user_id, username)
|
52
|
+
)
|
53
|
+
RocketChat::Token.new response['data']
|
54
|
+
end
|
55
|
+
|
40
56
|
#
|
41
57
|
# users.update REST API
|
42
58
|
# @param [String] id Rocket.Chat user id
|
@@ -141,6 +157,21 @@ module RocketChat
|
|
141
157
|
)['success']
|
142
158
|
end
|
143
159
|
|
160
|
+
#
|
161
|
+
# users.resetAvatar REST API
|
162
|
+
# @param [String] user_id user to update (optional)
|
163
|
+
# @param [String] username Username (optional)
|
164
|
+
# @return [Boolean]
|
165
|
+
# @raise [HTTPError, StatusError]
|
166
|
+
#
|
167
|
+
def reset_avatar(user_id: nil, username: nil)
|
168
|
+
session.request_json(
|
169
|
+
'/api/v1/users.resetAvatar',
|
170
|
+
method: :post,
|
171
|
+
body: user_params(user_id, username)
|
172
|
+
)['success']
|
173
|
+
end
|
174
|
+
|
144
175
|
private
|
145
176
|
|
146
177
|
attr_reader :session
|
@@ -29,6 +29,7 @@ module RocketChat
|
|
29
29
|
check_response response, fail_unless_ok
|
30
30
|
|
31
31
|
response_json = JSON.parse(response.body)
|
32
|
+
options[:debug].puts("Response: #{response_json.inspect}") if options[:debug]
|
32
33
|
check_response_json response_json, upstreamed_errors
|
33
34
|
|
34
35
|
response_json
|
@@ -79,6 +80,7 @@ module RocketChat
|
|
79
80
|
|
80
81
|
def create_http(options)
|
81
82
|
http = Net::HTTP.new(server.host, server.port)
|
83
|
+
http.set_debug_output(options[:debug]) if options[:debug]
|
82
84
|
|
83
85
|
if server.scheme == 'https'
|
84
86
|
http.use_ssl = true
|
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.5
|
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-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.6.12
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Rocket.Chat REST API v1 for Ruby
|