2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/brauchbar/request.rb', line 2
def self.execute(params = {})
raise ArgumentError.new('Method option required') if params[:method].nil?
raise ArgumentError.new('Unsupported Method') unless %w{ get }.include?(params[:method].to_s)
raise ArgumentError.new('URI option required') if params[:uri].nil?
begin
URI.parse(params[:uri])
rescue URI::InvalidURIError => e
raise ArgumentError.new('Invalid URI')
end
params[:headers] ||= {}
session = Patron::Session.new
response = session.request(params[:method], params[:uri], params[:headers])
Brauchbar::Response.new response
end
|