Class: Rosemary::OauthClient
- Defined in:
- lib/rosemary/oauth_client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ OAuth::AccessToken
readonly
The access token to be used for all write access.
Instance Method Summary collapse
-
#delete(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth DELETE request.
-
#get(url, header = {}) ⇒ Object
Execute a signed OAuth GET request.
-
#initialize(access_token) ⇒ OauthClient
constructor
A new instance of OauthClient.
-
#post(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth POST request.
-
#put(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth PUT request.
Constructor Details
#initialize(access_token) ⇒ OauthClient
Returns a new instance of OauthClient.
8 9 10 |
# File 'lib/rosemary/oauth_client.rb', line 8 def initialize(access_token) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ OAuth::AccessToken (readonly)
The access token to be used for all write access
5 6 7 |
# File 'lib/rosemary/oauth_client.rb', line 5 def access_token @access_token end |
Instance Method Details
#delete(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth DELETE request.
Unfortunately the OSM API requires to send an XML representation of the Element to be delete in the body of the request. The OAuth library does not support sending any information in the request body. If you know a workaround please fork and improve.
35 36 37 38 39 |
# File 'lib/rosemary/oauth_client.rb', line 35 def delete(url, ={}, header={}) raise NotImplemented.new("Delete with Oauth and OSM is not supported") # body = options[:body] # access_token.delete(url, {'Content-Type' => 'application/xml' }) end |
#get(url, header = {}) ⇒ Object
Execute a signed OAuth GET request.
15 16 17 |
# File 'lib/rosemary/oauth_client.rb', line 15 def get(url, header={}) access_token.get(url, {'Content-Type' => 'application/xml' }) end |
#post(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth POST request.
45 46 47 48 |
# File 'lib/rosemary/oauth_client.rb', line 45 def post(url, ={}, header={}) body = [:body] access_token.post(url, body, {'Content-Type' => 'application/xml' }) end |
#put(url, options = {}, header = {}) ⇒ Object
Execute a signed OAuth PUT request.
23 24 25 26 |
# File 'lib/rosemary/oauth_client.rb', line 23 def put(url, ={}, header={}) body = [:body] access_token.put(url, body, {'Content-Type' => 'application/xml' }) end |