Module: ActiveZuora::Generate

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_zuora/generate.rb

Instance Method Summary collapse

Instance Method Details

#generateObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_zuora/generate.rb', line 17

def generate
  self.result = self.class.connection.request(:generate) do |soap|
    soap.body do |xml|
      build_xml(xml, soap,
        :namespace => soap.namespace,
        :element_name => :zObjects,
        :force_type => true)
    end
  end[:generate_response][:result]

  if result[:success]
    self.id = result[:id]
    self.status = 'Draft'
    clear_changed_attributes
    true
  else
    add_zuora_errors(result[:errors])
    false
  end
end

#generate!Object


38
39
40
# File 'lib/active_zuora/generate.rb', line 38

def generate!
  raise "Could not generate: #{errors.full_messages.join ', '}" unless generate
end