Class: RocketChat::Server
- Inherits:
-
Object
- Object
- RocketChat::Server
- Includes:
- RequestHelper
- Defined in:
- lib/rocket_chat/server.rb
Overview
Rocket.Chat Server
Constant Summary
Constants included from RequestHelper
RequestHelper::DEFAULT_REQUEST_OPTIONS
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Server options.
Attributes included from RequestHelper
Instance Method Summary collapse
-
#info ⇒ Info
Info REST API.
-
#initialize(server, options = {}) ⇒ Server
constructor
A new instance of Server.
-
#login(username, password) ⇒ Session
Login REST API.
- #request_json(path, options = {}) ⇒ Object
Methods included from RequestHelper
Constructor Details
#initialize(server, options = {}) ⇒ Server
Returns a new instance of Server.
17 18 19 20 |
# File 'lib/rocket_chat/server.rb', line 17 def initialize(server, = {}) self.server = server @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Server options
11 12 13 |
# File 'lib/rocket_chat/server.rb', line 11 def @options end |
Instance Method Details
#info ⇒ Info
Info REST API
27 28 29 30 |
# 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) ⇒ Session
Login REST API
39 40 41 42 43 44 45 46 47 48 49 |
# 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 = {}) ⇒ Object
51 52 53 |
# File 'lib/rocket_chat/server.rb', line 51 def request_json(path, = {}) super(path, @options.merge()) end |