Method: Rev::HttpClient#get_binary

Defined in:
lib/rev-api/http_client.rb

#get_binary(operation, headers = {}) {|resp| ... } ⇒ Net::HTTP::Response

Performs HTTP GET of binary data. Note, unlike post, this returns a Net::HTTP::Response, not HTTParty::Response.

If this method is passed a block, will pass response to that block. in that case the response is not yet read into memory, so the block can read it progressively. otherwise, returns the response.

Parameters:

  • operation (String)

    URL suffix describing specific operation, like ‘/orders’

  • headers (Hash) (defaults to: {})

    hash of headers to use for the request

Yield Parameters:

  • resp (Net::HTTP::Response)

    the response, ready to be read

Returns:

  • (Net::HTTP::Response)

    response



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rev-api/http_client.rb', line 47

def get_binary(operation, headers = {}, &block)
  uri = URI.parse("#{self.class.base_uri}#{operation}")
  headers = @default_headers.merge(headers)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  get = Net::HTTP::Get.new(uri.request_uri, headers)
  if block_given?
    http.request(get) do |resp|
      yield resp
    end
  else
    http.request(get)
  end
end