Sha256: 3ebed75dadc94a6e2dc90e714e84169d221c238589383fbb9b5c2b4bd55887b4
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
require 'httparty' require_relative 'endpoint' require_relative 'request' module Mattermost class Client import Mattermost::Endpoint import Mattermost::Request attr_accessor :server, :token def initialize(server) self.server = server self.base_uri = "#{server}/api/v4" end def login(username, password) login_request = post('/users/login', :body => {:login_id => uername, :password => password}.to_json) self.token = login_request.headers['token'] update_token end def logout self.token = nil update_token end def use_access_token(token) self.token = token update_token end def connected? getMe().success? end private def update_token self.headers "Authorization: Bearer #{token}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mattermost-api4-ruby-0.0.1 | lib/mattermost/client.rb |