Method: Insightly::ReadWrite#post_collection

Defined in:
lib/insightly/read_write.rb

#post_collection(path, params, content_selector = :json) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/insightly/read_write.rb', line 20

def post_collection(path, params, content_selector = :json)
  if content_selector == :xml_raw
    content_type = :xml
  else
    content_type = content_selector
  end
  response = RestClient::Request.new(:method => :post,
                                     :url => "#{config.endpoint}/#{path.to_s}",
                                     :user => config.api_key,
                                     :password => "",
                                     :payload => params,
                                     :headers => {:accept => content_type, :content_type => content_type}).execute
  process(response, content_selector)
end