Module: ActiveZuora::Base

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

Defined Under Namespace

Modules: ClassMethods

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.connectionObject

Returns the value of attribute connection.


12
13
14
# File 'lib/active_zuora/base.rb', line 12

def connection
  @connection
end

Instance Method Details

#add_zuora_errors(zuora_errors) ⇒ Object


48
49
50
51
52
# File 'lib/active_zuora/base.rb', line 48

def add_zuora_errors(zuora_errors)
  return if zuora_errors.blank?
  zuora_errors = [zuora_errors] unless zuora_errors.is_a?(Array)
  zuora_errors.each { |error| errors.add(:base, error[:message].capitalize) }
end

#build_xml(xml, soap, options = {}) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/active_zuora/base.rb', line 34

def build_xml(xml, soap, options={})
  namespace = options.delete(:namespace) || self.namespace
  qualifier = soap.namespace_by_uri(namespace)
  custom_element_name = options.delete(:element_name)
  element_name = custom_element_name || zuora_object_name
  attributes = options.delete(:force_type) ? 
    { "xsi:type" => "#{qualifier}:#{zuora_object_name}" } : {}
  xml.tag!(qualifier, element_name.to_sym, attributes) do
    xml_field_names.map { |field_name| get_field!(field_name) }.each do |field|
      field.build_xml(xml, soap, send(field.name), options)
    end
  end
end

#xml_field_namesObject


27
28
29
30
31
32
# File 'lib/active_zuora/base.rb', line 27

def xml_field_names
  # Which field names should be rendered during build_xml.
  # Choose only field names that have been changed.
  # Make sure the order in fields is maintained.
  field_names & changed.map(&:to_sym)
end