Class: ExvoAuth::Autonomous::Consumer
- Inherits:
-
Base
- Object
- Base
- ExvoAuth::Autonomous::Consumer
show all
- Includes:
- Http
- Defined in:
- lib/exvo_auth/autonomous/consumer.rb
Instance Attribute Summary
Attributes inherited from Base
#params
Instance Method Summary
collapse
Methods included from Http
#delete, #get, #head, #options, #post, #put
Constructor Details
#initialize(params = {}) ⇒ Consumer
Returns a new instance of Consumer.
4
5
6
7
|
# File 'lib/exvo_auth/autonomous/consumer.rb', line 4
def initialize(params = {})
super
validate_params!(:provider_id)
end
|
Instance Method Details
#authorization ⇒ Object
21
22
23
24
25
|
# File 'lib/exvo_auth/autonomous/consumer.rb', line 21
def authorization
@@cache.fetch(params) do
authorization!
end
end
|
#authorization! ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/exvo_auth/autonomous/consumer.rb', line 27
def authorization!
response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:provider_id])}.json")
if response["authorization"]
@@cache.write(params, response["authorization"])
else
raise "Unauthorized"
end
end
|
#base_uri ⇒ Object
9
10
11
|
# File 'lib/exvo_auth/autonomous/consumer.rb', line 9
def base_uri
authorization["url"]
end
|
#password ⇒ Object
17
18
19
|
# File 'lib/exvo_auth/autonomous/consumer.rb', line 17
def password
authorization["access_token"]
end
|