class ExvoAuth::Autonomous::Consumer

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method ExvoAuth::Autonomous::Base::new
# File lib/exvo_auth/autonomous/consumer.rb, line 4
def initialize(params = {})
  super
  validate_params!(:app_id)
end

Public Instance Methods

authorization() click to toggle source
# File lib/exvo_auth/autonomous/consumer.rb, line 21
def authorization
  @@cache.fetch(params) do
    authorization!
  end
end
authorization!() click to toggle source
# File lib/exvo_auth/autonomous/consumer.rb, line 27
def authorization!
  response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:app_id])}.json")

  if response["authorization"]
    @@cache.write(params, response["authorization"])
  else
    raise "Authorization not found. You need an auhorization to contact provider app (#{ params[:app_id] })"
  end
end
base_uri() click to toggle source
# File lib/exvo_auth/autonomous/consumer.rb, line 9
def base_uri
  authorization["url"]
end
password() click to toggle source
# File lib/exvo_auth/autonomous/consumer.rb, line 17
def password
  authorization["access_token"]
end
username() click to toggle source
# File lib/exvo_auth/autonomous/consumer.rb, line 13
def username
  Exvo::Helpers.auth_client_id
end