Class: Ingenico::Connect::SDK::Domain::Payment::ShoppingCart

Inherits:
Ingenico::Connect::SDK::DataObject show all
Defined in:
lib/ingenico/connect/sdk/domain/payment/shopping_cart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ingenico::Connect::SDK::DataObject

new_from_hash

Instance Attribute Details

#amount_breakdownObject

Array of AmountBreakdown



16
17
18
# File 'lib/ingenico/connect/sdk/domain/payment/shopping_cart.rb', line 16

def amount_breakdown
  @amount_breakdown
end

#itemsObject

Array of LineItem



19
20
21
# File 'lib/ingenico/connect/sdk/domain/payment/shopping_cart.rb', line 19

def items
  @items
end

Instance Method Details

#from_hash(hash) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ingenico/connect/sdk/domain/payment/shopping_cart.rb', line 28

def from_hash(hash)
  super
  if hash.has_key?('amountBreakdown')
    if !(hash['amountBreakdown'].is_a? Array)
      raise TypeError, "value '%s' is not an Array" % [hash['amountBreakdown']]
    end
    @amount_breakdown = []
    hash['amountBreakdown'].each do |e|
      @amount_breakdown << Ingenico::Connect::SDK::Domain::Payment::AmountBreakdown.new_from_hash(e)
    end
  end
  if hash.has_key?('items')
    if !(hash['items'].is_a? Array)
      raise TypeError, "value '%s' is not an Array" % [hash['items']]
    end
    @items = []
    hash['items'].each do |e|
      @items << Ingenico::Connect::SDK::Domain::Payment::LineItem.new_from_hash(e)
    end
  end
end

#to_hObject



21
22
23
24
25
26
# File 'lib/ingenico/connect/sdk/domain/payment/shopping_cart.rb', line 21

def to_h
  hash = super
  add_to_hash(hash, 'amountBreakdown', @amount_breakdown)
  add_to_hash(hash, 'items', @items)
  hash
end