Skip to content

Latest commit

 

History

History
86 lines (50 loc) · 2.2 KB

groups.md

File metadata and controls

86 lines (50 loc) · 2.2 KB

Groups API

Groups are RocketChat's private rooms.

groups.list

N.B. groups.list, contrary to the other lists can only be used for listing

require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
groups = session.groups.list(offset: 40)

groups.addAll

require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.groups.add_all(room_id: 'ByehQjC44FwMeiLbX')

Optional parameter for add_all is active_users_only (default false)

N.B. the addAll API endpoint requires the calling user to have the admin role

groups.addOwner

require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.groups.add_owner(name: 'some_groupname', username: 'some_username')

Either room_id (RocketChat's ID) or name can be used. The same applies to user_id and username.

groups.removeOwner

To remove an owner from a group, the same options as an add_owner request can be used.

groups.addModerator

To add a moderator to a group, the same options as an add_owner request can be used.

groups.removeModerator

To remove a moderator from a group, the same options as an add_owner request can be used.

groups.members

This method returns the users of participants of a private group.

require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.groups.members(name: 'some_channel_name')

channels.upload_file

Upload file to the room

require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.groups.upload_file(room_id: 'GENERAL', file: File, filename: "Optional. The name of the file to use.", content_type: "Optional. The content type of the uploaded file", msg: "Optional Message", description: "Optional Description", tmid: "Optional thread message id")