class RocketChat::Server

Rocket.Chat Server

Attributes

options[R]

Server options

Public Class Methods

new(server, options = {}) click to toggle source

@param [URI, String] server Server URI @param [Hash] options Server options

# File lib/rocket_chat/server.rb, line 17
def initialize(server, options = {})
  self.server = server
  @options = options
end

Public Instance Methods

info() click to toggle source

Info REST API @return [Info] Rocket.Chat Info @raise [HTTPError, StatusError]

# File lib/rocket_chat/server.rb, line 27
def info
  response = request_json '/api/v1/info', fail_unless_ok: true
  Info.new response['info']
end
login(username, password) click to toggle source

Login REST API @param [String] username Username @param [String] password Password @return [Session] Rocket.Chat Session @raise [HTTPError, StatusError]

# File lib/rocket_chat/server.rb, line 39
def login(username, password)
  response = request_json(
    '/api/v1/login',
    method: :post,
    body: {
      username: username,
      password: password
    }
  )
  Session.new self, Token.new(response['data'])
end
request_json(path, options = {}) click to toggle source
Calls superclass method RocketChat::RequestHelper#request_json
# File lib/rocket_chat/server.rb, line 51
def request_json(path, options = {})
  super(path, @options.merge(options))
end