Class: OnlinePayments::SDK::Domain::ValueMappingElement

Inherits:
OnlinePayments::SDK::DataObject show all
Defined in:
lib/onlinepayments/sdk/domain/value_mapping_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OnlinePayments::SDK::DataObject

new_from_hash

Instance Attribute Details

#display_elementsArray<OnlinePayments::SDK::Domain::PaymentProductFieldDisplayElement>

Returns the current value of display_elements.

Returns:



12
13
14
# File 'lib/onlinepayments/sdk/domain/value_mapping_element.rb', line 12

def display_elements
  @display_elements
end

#valueString

Returns the current value of value.

Returns:

  • (String)

    the current value of value



12
13
14
# File 'lib/onlinepayments/sdk/domain/value_mapping_element.rb', line 12

def value
  @value
end

Instance Method Details

#from_hash(hash) ⇒ Object



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

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 << OnlinePayments::SDK::Domain::PaymentProductFieldDisplayElement.new_from_hash(e)
    end
  end
  @value = hash['value'] if hash.key? 'value'
end

#to_hHash

Returns:

  • (Hash)


17
18
19
20
21
22
# File 'lib/onlinepayments/sdk/domain/value_mapping_element.rb', line 17

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