Class: RedboothRuby::Session
- Inherits:
-
Object
- Object
- RedboothRuby::Session
- Defined in:
- lib/redbooth-ruby/session.rb
Constant Summary collapse
- OAUTH_URLS =
{ :site => 'https://redbooth.com/api/3', :authorize_url => 'https://redbooth.com/oauth2/authorize', :token_url => 'https://redbooth.com/oauth2/token' }
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
-
#oauth_verifier ⇒ Object
Returns the value of attribute oauth_verifier.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #client ⇒ Object
- #get_access_token_url ⇒ Object
-
#initialize(opts = {}) ⇒ Session
constructor
A new instance of Session.
- #valid? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Session
Returns a new instance of Session.
16 17 18 19 20 21 22 |
# File 'lib/redbooth-ruby/session.rb', line 16 def initialize(opts = {}) @token = opts[:token] @consumer_key = opts[:consumer_key] || RedboothRuby.configuration[:consumer_key] @consumer_secret = opts[:consumer_secret] || RedboothRuby.configuration[:consumer_secret] @oauth_verifier = opts[:oauth_verifier] @oauth_token = opts[:oauth_token] end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/redbooth-ruby/session.rb', line 6 def access_token @access_token end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
7 8 9 |
# File 'lib/redbooth-ruby/session.rb', line 7 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
7 8 9 |
# File 'lib/redbooth-ruby/session.rb', line 7 def consumer_secret @consumer_secret end |
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
8 9 10 |
# File 'lib/redbooth-ruby/session.rb', line 8 def oauth_token @oauth_token end |
#oauth_verifier ⇒ Object
Returns the value of attribute oauth_verifier.
8 9 10 |
# File 'lib/redbooth-ruby/session.rb', line 8 def oauth_verifier @oauth_verifier end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
6 7 8 |
# File 'lib/redbooth-ruby/session.rb', line 6 def refresh_token @refresh_token end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/redbooth-ruby/session.rb', line 6 def token @token end |
Instance Method Details
#client ⇒ Object
29 30 31 |
# File 'lib/redbooth-ruby/session.rb', line 29 def client @client ||= OAuth2::Client.new(consumer_key, consumer_secret, OAUTH_URLS) end |
#get_access_token_url ⇒ Object
33 34 35 36 37 |
# File 'lib/redbooth-ruby/session.rb', line 33 def get_access_token_url url = OAUTH_URLS[:request_token_url] url += "?oauth_verifier=#{oauth_verifier}" if oauth_verifier url += "&oauth_token=#{oauth_token}" if oauth_token end |
#valid? ⇒ Boolean
24 25 26 27 |
# File 'lib/redbooth-ruby/session.rb', line 24 def valid? return false unless token true end |