class Sensi::Account
Attributes
auth_response[RW]
headers[RW]
token[RW]
token_response[RW]
Public Class Methods
new(username, password)
click to toggle source
# File lib/sensi/account.rb, line 22 def initialize(username, password) @username = username @password = password self end
Public Instance Methods
get_connection_token()
click to toggle source
# File lib/sensi/account.rb, line 44 def get_connection_token @token_response = Curl.get(Sensi::API_URI + '/realtime/negotiate') do |req| req.headers['Cookie'] = @auth_cookie req.headers['Accept'] = 'application/json; version=1, */*; q=0.01' end @token = JSON.parse(@token_response.body)['ConnectionToken'] # @token_response = HTTParty.get( # Sensi::API_URI + '/realtime/negotiate', # headers: Sensi::DEFAULT_HEADERS # ) # @token = @token_response['ConnectionToken'] end
login()
click to toggle source
# File lib/sensi/account.rb, line 28 def login authorize(@username, @password) parse_cookies(@auth_response.get_fields('Set-Cookie')) save_auth_cookie add_auth_cookie_to_headers(@auth_cookie) get_connection_token end
logout()
click to toggle source
# File lib/sensi/account.rb, line 73 def logout HTTParty.delete( Sensi::API_URI + '/api/authorize', headers: {'Coookie' => @auth_cookie, 'Accept' => 'application/json; version=1, */*; q=0.01'} ) end