Class: TwoPerformant::OAuth
- Inherits:
-
Object
- Object
- TwoPerformant::OAuth
- Defined in:
- lib/two_performant/oauth.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#consumer ⇒ Object
Returns the value of attribute consumer.
Instance Method Summary collapse
- #delete(path, params) ⇒ Object
- #get(path, params_hash, params_xml) ⇒ Object
-
#initialize(options, host) ⇒ OAuth
constructor
A new instance of OAuth.
- #post(path, params_hash, params_xml) ⇒ Object
- #put(path, params_hash, params_xml) ⇒ Object
Constructor Details
#initialize(options, host) ⇒ OAuth
Returns a new instance of OAuth.
7 8 9 10 11 |
# File 'lib/two_performant/oauth.rb', line 7 def initialize(, host) consumer = ::OAuth::Consumer.new([:consumer_token], [:consumer_secret], {:site => host}) @access_token = ::OAuth::AccessToken.new(consumer, [:access_token], [:access_secret]) @headers = { 'Accept' => 'application/xml', 'Content-Type' => 'application/xml' } end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/two_performant/oauth.rb', line 5 def access_token @access_token end |
#consumer ⇒ Object
Returns the value of attribute consumer.
5 6 7 |
# File 'lib/two_performant/oauth.rb', line 5 def consumer @consumer end |
Instance Method Details
#delete(path, params) ⇒ Object
29 30 31 32 |
# File 'lib/two_performant/oauth.rb', line 29 def delete(path, params) response = access_token.delete("#{path}?#{params.to_params}") Crack::XML.parse(response.body) end |
#get(path, params_hash, params_xml) ⇒ Object
13 14 15 16 17 |
# File 'lib/two_performant/oauth.rb', line 13 def get(path, params_hash, params_xml) params_hash ||= {} response = access_token.get("#{path}?#{params_hash.to_params}") Crack::XML.parse(response.body) end |
#post(path, params_hash, params_xml) ⇒ Object
19 20 21 22 |
# File 'lib/two_performant/oauth.rb', line 19 def post(path, params_hash, params_xml) response = access_token.post(path, params_xml, @headers) Crack::XML.parse(response.body) end |
#put(path, params_hash, params_xml) ⇒ Object
24 25 26 27 |
# File 'lib/two_performant/oauth.rb', line 24 def put(path, params_hash, params_xml) response = access_token.put(path, params_xml, @headers) Crack::XML.parse(response.body) end |