require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
user = session.users.create('new_username', '[email protected]', 'New User', '123456',
active: true, send_welcome_email: false)
Optional parameters for create are:
:active, :roles, :join_default_channels, :require_password_change, :send_welcome_email, :verified, :custom_fields
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
user = session.users.create('new_username', '[email protected]', 'New User', '123456',
active: true, send_welcome_email: false)
token = session.users.create_token(user_id: user.id)
Either user_id (RocketChat's ID) or username can be used to target another user.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
user = session.users.update('LAjzCDLqggCT7B82M',
email: '[email protected]',
name: 'Updated Name',
roles: ['user', 'moderator']
)
Optional parameters for update are:
:username, :email, :password, :name, :active, :roles, :join_default_channels, :require_password_change, :send_welcome_email, :verified, :custom_fields
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
user = session.users.info(username: 'some_username')
Either user_id (RocketChat's ID) or username can be used.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
presence_status = session.users.get_presence(username: 'some_username')
Either user_id (RocketChat's ID) or username can be used.
To delete a user, the same options as an info request can be used (user_id
or username
).
N.B. list is also used for searching/querying
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
users = session.users.list(query: { email: '[email protected]' })
N.B. available since 0.55.0
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.users.reset_avatar
There are optional parameters user_id and username, that work if the setting user is allowed to set other's avatar.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.users.set_avatar('http://image_url')
There is an optional parameter user_id, that works if the setting user is allowed to set other's avatar.