module Mio::Requests

Public Class Methods

make_request(type, agent, url, opts, body=nil, content_type='application/vnd.nativ.mio.v1+json', accept='application/json') click to toggle source
# File lib/mio/requests.rb, line 4
def self.make_request type, agent, url, opts, body=nil, content_type='application/vnd.nativ.mio.v1+json', accept='application/json'
  if content_type.nil?
    content_type = 'application/vnd.nativ.mio.v1+json'
  end
  agent.method(type).call do |r|
    r.url url
    unless body.nil?
      if content_type.include? 'json'
        r.body = body.to_json
      else
        r.body = body
      end
    end
    r.headers[:content_type] = content_type
    r.headers[:accept]= accept
  end
end