Module: Rapidash::OAuthClient
- Defined in:
- lib/rapidash/oauth_client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#site ⇒ Object
Returns the value of attribute site.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #access_token_from_code(code, url) ⇒ Object
- #initialize(options) ⇒ Object
- #request(verb, url, options = {}) ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/rapidash/oauth_client.rb', line 6 def access_token @access_token end |
#secret ⇒ Object
Returns the value of attribute secret.
6 7 8 |
# File 'lib/rapidash/oauth_client.rb', line 6 def secret @secret end |
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/rapidash/oauth_client.rb', line 6 def site @site end |
#uid ⇒ Object
Returns the value of attribute uid.
6 7 8 |
# File 'lib/rapidash/oauth_client.rb', line 6 def uid @uid end |
Instance Method Details
#access_token_from_code(code, url) ⇒ Object
31 32 33 34 |
# File 'lib/rapidash/oauth_client.rb', line 31 def access_token_from_code(code, url) token = client.auth_code.get_token(code, :redirect_uri => url) self.access_token = token.token end |
#initialize(options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rapidash/oauth_client.rb', line 8 def initialize() [:uid, :secret, :site].each do |key| if [key] self.send("#{key.to_s}=".to_sym, [key]) else unless self.class.respond_to?(key) && send(key) raise ConfigurationError.new "Missing #{key} value" end end end self.access_token = [:access_token] if [:access_token] end |
#request(verb, url, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rapidash/oauth_client.rb', line 22 def request(verb, url, = {}) url = normalize_url(url) [:body] = [:body].to_json if [:body] [:raise_errors] = self.class.respond_to?(:raise_error) && self.class.raise_error response = oauth_access_token.send(verb.to_sym, "#{site}/#{url}", ) response.body end |