Method: AMEE::Data::Item.create_batch_without_category

Defined in:
lib/amee/data_item.rb

.create_batch_without_category(connection, category_path, items, options = {}) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/amee/data_item.rb', line 199

def self.create_batch_without_category(connection, category_path, items, options = {})
  if connection.format == :json
    options.merge! :profileItems => items
    post_data = options.to_json
  else
  options.merge!({:DataItems => items})
  post_data = options.to_xml(:root => "DataCategory", :skip_types => true, :skip_nil => true)
  end
  # Post to category
  response = connection.raw_post(category_path, post_data).body
  # Send back a category object containing all the created items
  unless response.empty?
    return AMEE::Data::Category.parse(connection, response)
  else
    return true
  end
end