This is a gem wrapping the v1 REST API for Rocket.Chat.
The gem is based on a fork of http://github.com/int2xx9/ruby-rocketchat however that gem implemented v0.1 of the Rocket.Chat API and it was not forward compatible. Thanks to @int2xx9 for the framework on which this gem was based
Add this line to your application's Gemfile:
gem 'rocketchat'
And then execute:
$ bundle
This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.54)
- /api/v1/login
- /api/v1/logout
- /api/v1/me
- /api/v1/channels.archive
- /api/v1/channels.create
- /api/v1/channels.delete
- /api/v1/channels.addAll
- /api/v1/channels.addOwner
- /api/v1/channels.removeOwner
- /api/v1/channels.addModerator
- /api/v1/channels.removeModerator
- /api/v1/channels.info
- /api/v1/channels.invite
- /api/v1/channels.join
- /api/v1/channels.leave
- /api/v1/channels.list
- /api/v1/channels.rename
- /api/v1/channels.setDescription
- /api/v1/channels.setJoinCode
- /api/v1/channels.setPurpose
- /api/v1/channels.setReadOnly
- /api/v1/channels.setTopic
- /api/v1/channels.setType
- /api/v1/channels.online
- /api/v1/channels.members
- /api/v1/channels.unarchive
- /api/v1/rooms.upload
- /api/v1/groups.archive
- /api/v1/groups.create
- /api/v1/groups.delete
- /api/v1/groups.addAll
- /api/v1/groups.addOwner
- /api/v1/groups.removeOwner
- /api/v1/groups.addModerator
- /api/v1/groups.removeModerator
- /api/v1/groups.info
- /api/v1/groups.invite
- /api/v1/groups.leave
- /api/v1/groups.list
- /api/v1/groups.rename
- /api/v1/groups.setDescription
- /api/v1/groups.setPurpose
- /api/v1/groups.setReadOnly
- /api/v1/groups.setTopic
- /api/v1/groups.setType
- /api/v1/groups.members
- /api/v1/groups.unarchive
- /api/v1/rooms.upload
- /api/v1/users.create
- /api/v1/users.createToken
- /api/v1/users.delete
- /api/v1/users.getPresence
- /api/v1/users.info
- /api/v1/users.list
- /api/v1/users.resetAvatar
- /api/v1/users.setAvatar
- /api/v1/users.update
To get Rocket.Chat version
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
info = rocket_server.info
puts "Rocket.Chat version: #{info.version}"
To logout from a server:
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
# ... use the API ...
session.logout
To debug the communications between the gem and Rocket.Chat, there is a debug option. It accepts a stream for logging.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/', debug: $stderr)
For details of specific APIs:
Bug reports and pull requests are welcome on GitHub at https://github.com/abrom/rocketchat-ruby.
Note that spec tests are appreciated to minimise regressions. Before submitting a PR, please ensure that:
$ rspec
and
$ rubocop
both succeed
The gem is available as open source under the terms of the MIT License.