Sha256: 640cddde9524d007ddbc85557213694af2a2e47bcab35c1ba3326b28d6e59358

Contents?: true

Size: 940 Bytes

Versions: 8

Compression:

Stored size: 940 Bytes

Contents

require 'rest_client'

module Airborne
  module RestClientRequester
    def make_request(method, url, options = {})
      headers = { content_type: :json }.merge(options[:headers] || {})
      base_headers = Airborne.configuration.headers || {}
      headers = base_headers.merge(headers)
      res = if method == :post || method == :patch || method == :put
              begin
                request_body = options[:body].nil? ? '' : options[:body]
                request_body = request_body.to_json if options[:body].is_a?(Hash)
                RestClient.send(method, get_url(url), request_body, headers)
              rescue RestClient::Exception => e
                e.response
              end
            else
              begin
                RestClient.send(method, get_url(url), headers)
              rescue RestClient::Exception => e
                e.response
              end
            end
      res
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
airborne-0.2.2 lib/airborne/rest_client_requester.rb
airborne-0.2.1 lib/airborne/rest_client_requester.rb
airborne-0.2.0 lib/airborne/rest_client_requester.rb
airborne-0.1.20 lib/airborne/rest_client_requester.rb
airborne-0.1.19 lib/airborne/rest_client_requester.rb
airborne-0.1.18 lib/airborne/rest_client_requester.rb
airborne-0.1.17 lib/airborne/rest_client_requester.rb
airborne-0.1.16 lib/airborne/rest_client_requester.rb