rocketchat 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3c6a81c9b24af32e67ddee2d35a461271507a73
4
- data.tar.gz: 2adb561c2bbe7474cfdf961dcc8b576bb02f549a
3
+ metadata.gz: dd58bd7162f1bf9a4b5d6c5a7cf889c670fc3307
4
+ data.tar.gz: 39d2f4288d3d42642ec58003e377734c2a5989b9
5
5
  SHA512:
6
- metadata.gz: 4719b5dce2ba7c22951e6a1848eeb999f3b89ce34eb056f1265b4b21bb688172cf842774f6800b0fef7628842963c035743f8e44b84bc9087c045925d758de38
7
- data.tar.gz: 066d66b376d3e6529874ea1f397319e433c5b7e1c65206d5b0326456a99834cf6bd7daeefff7fe6b96d19f72fbd83366f534ae1620e9b3417f6031ad4237ace7
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.
@@ -1,3 +1,3 @@
1
1
  module RocketChat
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -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 [String] new_email Email
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, new_email, new_name, options = {})
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
- options = Util.slice_hash(
67
- options, :active, :roles, :join_default_channels, :require_password_change,
68
- :send_welcome_email, :verified, :custom_fields, :username, :password
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.3
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-14 00:00:00.000000000 Z
12
+ date: 2017-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler