Class: Rosemary::OauthClient

Inherits:
Client
  • Object
show all
Defined in:
lib/rosemary/oauth_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ 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_tokenOAuth::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.

Raises:



35
36
37
38
39
# File 'lib/rosemary/oauth_client.rb', line 35

def delete(url, options={}, 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, options={}, header={})
  body = options[: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, options={}, header={})
  body = options[:body]
  access_token.put(url, body, {'Content-Type' => 'application/xml' })
end