Class: Flex::HttpClients::RestClient

Inherits:
Base
  • Object
show all
Defined in:
lib/flex/http_clients/rest_client.rb

Defined Under Namespace

Modules: ResponseExtension

Instance Attribute Summary

Attributes inherited from Base

#base_uri, #options, #raise_proc

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Flex::HttpClients::Base

Instance Method Details

#request(method, path, data = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/flex/http_clients/rest_client.rb', line 5

def request(method, path, data=nil)
  url  = "#{base_uri}#{path}"
  opts = options.merge( :method  => method.to_s.downcase.to_sym,
                        :url     => url,
                        :payload => data )
  response = ::RestClient::Request.new( opts ).execute
  extend_response(response, url)

rescue ::RestClient::ExceptionWithResponse => e
  extend_response(e.response, url)
end