rocketchat 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +36 -0
- data/lib/rocket_chat/gem_version.rb +1 -1
- data/lib/rocket_chat/messages/user.rb +9 -12
- 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: dd58bd7162f1bf9a4b5d6c5a7cf889c670fc3307
|
4
|
+
data.tar.gz: 39d2f4288d3d42642ec58003e377734c2a5989b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25017410a5502a557e9a59887298bf9824b8d6173ab2852ec3c4da05abea15143fc49eff19382abc0f3706c9a6f175474d0c8065d9cc91a827ef3dc63eaf6fba
|
7
|
+
data.tar.gz: af8b16ad88a70dbb2ec700a63bbdf206307eb5c4637fb4f6abb2c3d2f15e77aaa79422f32cc9cf6a650afcb0f3034234f90f9213456a91dcc2c38a9c661f02ba
|
data/README.md
CHANGED
@@ -37,6 +37,7 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
37
37
|
|
38
38
|
### Users
|
39
39
|
* /api/v1/users.create
|
40
|
+
* /api/v1/users.update
|
40
41
|
|
41
42
|
|
42
43
|
## Usage
|
@@ -64,6 +65,41 @@ session.logout
|
|
64
65
|
```
|
65
66
|
|
66
67
|
|
68
|
+
To create a user:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
require 'rocketchat'
|
72
|
+
|
73
|
+
rocket_server = RocketChat::Server.new('http://your.server.address/')
|
74
|
+
session = rocket_server.login('username', 'password')
|
75
|
+
session.users.create('new_username', 'user@example.com', 'New User', '123456',
|
76
|
+
active: true, send_welcome_email: false)
|
77
|
+
```
|
78
|
+
|
79
|
+
Optional parameters for create are:
|
80
|
+
|
81
|
+
:active, :roles, :join_default_channels, :require_password_change, :send_welcome_email, :verified, :custom_fields
|
82
|
+
|
83
|
+
|
84
|
+
To update a user:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
require 'rocketchat'
|
88
|
+
|
89
|
+
rocket_server = RocketChat::Server.new('http://your.server.address/')
|
90
|
+
session = rocket_server.login('username', 'password')
|
91
|
+
session.users.update('LAjzCDLqggCT7B82M',
|
92
|
+
email: 'updated@example.com',
|
93
|
+
name: 'Updated Name',
|
94
|
+
roles: ['user', 'moderator']
|
95
|
+
)
|
96
|
+
```
|
97
|
+
|
98
|
+
Optional parameters for update are:
|
99
|
+
|
100
|
+
:username, :email, :password, :name, :active, :roles, :join_default_channels, :require_password_change, :send_welcome_email, :verified, :custom_fields
|
101
|
+
|
102
|
+
|
67
103
|
## Contributing
|
68
104
|
|
69
105
|
Bug reports and pull requests are welcome on GitHub at https://github.com/abrom/rocketchat-ruby.
|
@@ -38,21 +38,17 @@ module RocketChat
|
|
38
38
|
#
|
39
39
|
# users.update REST API
|
40
40
|
# @param [String] id Rocket.Chat user id
|
41
|
-
# @param [
|
42
|
-
# @param [String] new_name Name
|
41
|
+
# @param [Hash] options User properties to update
|
43
42
|
# @return [User]
|
44
43
|
# @raise [HTTPError, StatusError]
|
45
44
|
#
|
46
|
-
def update(id,
|
45
|
+
def update(id, options = {})
|
47
46
|
response = session.request_json(
|
48
47
|
'/api/v1/users.update',
|
49
48
|
method: :post,
|
50
49
|
body: {
|
51
50
|
userId: id,
|
52
|
-
data:
|
53
|
-
email: new_email,
|
54
|
-
name: new_name
|
55
|
-
}.merge(user_option_hash(options))
|
51
|
+
data: user_option_hash(options, true)
|
56
52
|
}
|
57
53
|
)
|
58
54
|
RocketChat::User.new response['user']
|
@@ -62,11 +58,12 @@ module RocketChat
|
|
62
58
|
|
63
59
|
attr_reader :session
|
64
60
|
|
65
|
-
def user_option_hash(options)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
61
|
+
def user_option_hash(options, include_personal_fields = false)
|
62
|
+
args = [options, :active, :roles, :join_default_channels, :require_password_change,
|
63
|
+
:send_welcome_email, :verified, :custom_fields]
|
64
|
+
args += [:username, :email, :name, :password] if include_personal_fields
|
65
|
+
|
66
|
+
options = Util.slice_hash(*args)
|
70
67
|
return {} if options.empty?
|
71
68
|
|
72
69
|
new_hash = {}
|
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.0.
|
4
|
+
version: 0.0.4
|
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-04-
|
12
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|