Class: WEB_API::SignetMethod

Inherits:
ClientMethod show all
Defined in:
lib/web_api/signet.rb

Constant Summary

Constants inherited from WebApiMethod

WebApiMethod::OK, WebApiMethod::SCHEMES, WebApiMethod::SSL, WebApiMethod::TYPES

Instance Attribute Summary

Attributes inherited from ClientMethod

#client

Attributes inherited from WebApiMethod

#base, #path, #type, #uri

Instance Method Summary collapse

Methods inherited from ClientMethod

#http, #initialize

Methods inherited from WebApiMethod

#arg_map, #args_map, #call, #escape, #headers, #http, #initialize, #kv_map, #pathquery

Constructor Details

This class inherits a constructor from WEB_API::ClientMethod

Instance Method Details

#fetch_protected_resource(url, headers = nil, type = 'GET', body = nil) ⇒ Object



9
10
11
12
13
14
# File 'lib/web_api/signet.rb', line 9

def fetch_protected_resource(url, headers=nil, type='GET', body=nil)
  options = {:uri => url, :method => type}
  options[:body]    = body    if body
  options[:headers] = headers if headers
  parse client.fetch_protected_resource(options)
end

#get(args) ⇒ Object



20
21
22
23
# File 'lib/web_api/signet.rb', line 20

def get(args)
  url  = "#{uri.scheme}://#{uri.host}#{pathquery(args)}"
  fetch_protected_resource(url, headers(args))
end

#parse(response) ⇒ Object

Raises:



4
5
6
7
# File 'lib/web_api/signet.rb', line 4

def parse(response)
  raise ResponseError, response.body unless OK === response.status
  response.body
end

#post(args) ⇒ Object



16
17
18
# File 'lib/web_api/signet.rb', line 16

def post(args)
  fetch_protected_resource(uri.to_s, headers(args), 'POST', data(args))
end