Sha256: d00b259a16b165940137795bf47bb870279783625a85e08a4d331b114523461b

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module RocketChat
  #
  # Rocket.Chat Server
  #
  class Server
    include RocketChat::RequestHelper

    # Server options
    attr_reader :options

    #
    # @param [URI, String] server Server URI
    # @param [Hash] options Server options
    #
    def initialize(server, options = {})
      self.server = server
      @options = options
    end

    #
    # Info REST API
    # @return [Info] Rocket.Chat Info
    # @raise [HTTPError, StatusError]
    #
    def info
      response = request_json '/api/v1/info', fail_unless_ok: true
      Info.new response['info']
    end

    #
    # Login REST API
    # @param [String] username Username
    # @param [String] password Password
    # @return [Session] Rocket.Chat Session
    # @raise [HTTPError, StatusError]
    #
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rocketchat-0.0.5 lib/rocket_chat/server.rb
rocketchat-0.0.4 lib/rocket_chat/server.rb
rocketchat-0.0.3 lib/rocket_chat/server.rb
rocketchat-0.0.2 lib/rocket_chat/server.rb
rocketchat-0.0.1 lib/rocket_chat/server.rb