Class: Ingenico::Direct::SDK::Domain::ValueMappingElement

Inherits:
Ingenico::Direct::SDK::DataObject show all
Defined in:
lib/ingenico/direct/sdk/domain/value_mapping_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ingenico::Direct::SDK::DataObject

new_from_hash

Instance Attribute Details

#display_elementsArray<Ingenico::Direct::SDK::Domain::PaymentProductFieldDisplayElement>

Returns the current value of display_elements.

Returns:



13
14
15
# File 'lib/ingenico/direct/sdk/domain/value_mapping_element.rb', line 13

def display_elements
  @display_elements
end

#valueString

Returns the current value of value.

Returns:

  • (String)

    the current value of value



13
14
15
# File 'lib/ingenico/direct/sdk/domain/value_mapping_element.rb', line 13

def value
  @value
end

Instance Method Details

#from_hash(hash) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ingenico/direct/sdk/domain/value_mapping_element.rb', line 25

def from_hash(hash)
  super
  if hash.key? 'displayElements'
    raise TypeError, "value '%s' is not an Array" % [hash['displayElements']] unless hash['displayElements'].is_a? Array
    @display_elements = []
    hash['displayElements'].each do |e|
      @display_elements << Ingenico::Direct::SDK::Domain::PaymentProductFieldDisplayElement.new_from_hash(e)
    end
  end
  @value = hash['value'] if hash.key? 'value'
end

#to_hHash

Returns:

  • (Hash)


18
19
20
21
22
23
# File 'lib/ingenico/direct/sdk/domain/value_mapping_element.rb', line 18

def to_h
  hash = super
  hash['displayElements'] = @display_elements.collect(&:to_h) if @display_elements
  hash['value'] = @value unless @value.nil?
  hash
end