module RevereMobile::Client::Authentication

Public Instance Methods

login() click to toggle source
# File lib/revere_mobile/client/authentication.rb, line 9
def login

  temp_cookie_jar = HTTP::CookieJar.new

  conn = Faraday.new(url: config.api_endpoint) do |f|
    f.use :cookie_jar, jar: temp_cookie_jar
    f.adapter Faraday.default_adapter
  end

  response = conn.post do |req|
    req.url 'authenticate'
    req.headers['Content-Type'] = 'application/json'
    req.body = JSON.generate({ username: config.username, password: config.password })
  end


  config.session = temp_cookie_jar
  response
end
logout() click to toggle source
# File lib/revere_mobile/client/authentication.rb, line 33
def logout
  post(path: 'authenticate/logout')
end
who_am_i() click to toggle source
# File lib/revere_mobile/client/authentication.rb, line 29
def who_am_i
  get(path: 'authenticate/whoami')
end