Sha256: a1d50570ef5c44bf9e067305f7013de1e7ccd37bdadfac3a605efb07a6465153

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 Bytes

Contents

class HttpClient
  require 'httparty'
  include HTTParty

  # sends http request with given method, uri and data and returns servers response
  def send_request(method, uri, data=nil)
    build_response(self.class.send(method, uri, data))
  end

  # returns struct containing response.code, headers, body and message
  # this is only for easily interfaceing another http client
  def build_response(raw_response)
    response_struct = Struct.new(:code, :message, :headers, :body)
    response = response_struct.new
    response.code = raw_response.code
    response.message = raw_response.message
    response.headers = raw_response.headers
    response.body = raw_response.body
    response
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apirunner-0.1.1 lib/http_client.rb
apirunner-0.1.0 lib/http_client.rb
apirunner-0.0.13 lib/http_client.rb
apirunner-0.0.12 lib/http_client.rb