Method: Quickbooks::Service::ServiceCrud#create

Defined in:
lib/quickbooks/service/service_crud.rb

#create(entity, options = {}) ⇒ Object Also known as: update



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/quickbooks/service/service_crud.rb', line 48

def create(entity, options = {})
  raise Quickbooks::InvalidModelException.new(entity.errors.full_messages.join(',')) unless entity.valid?
  xml = entity.to_xml_ns(options)

  response = do_http_post(url_for_resource(model.resource_for_singular), valid_xml_document(xml), options[:query])
  if response.code.to_i == 200
    model.from_xml(parse_singular_entity_response(model, response.plain_body))
  else
    nil
  end
end