Class: WEB_API::SignetMethod

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

Constant Summary collapse

OK =
200

Constants inherited from WebApiMethod

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



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

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



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

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

#parse(response) ⇒ Object

Raises:



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

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

#post(args) ⇒ Object



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

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