Class: Ingenico::Direct::SDK::Domain::ShoppingCart

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

new_from_hash

Instance Attribute Details

#amount_breakdownArray<Ingenico::Direct::SDK::Domain::AmountBreakdown>

Returns the current value of amount_breakdown.

Returns:



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

def amount_breakdown
  @amount_breakdown
end

#gift_card_purchaseIngenico::Direct::SDK::Domain::GiftCardPurchase

Returns the current value of gift_card_purchase.

Returns:



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

def gift_card_purchase
  @gift_card_purchase
end

#is_pre_ordertrue/false

Returns the current value of is_pre_order.

Returns:

  • (true/false)

    the current value of is_pre_order



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

def is_pre_order
  @is_pre_order
end

#itemsArray<Ingenico::Direct::SDK::Domain::LineItem>

Returns the current value of items.

Returns:



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

def items
  @items
end

#pre_order_item_availability_dateString

Returns the current value of pre_order_item_availability_date.

Returns:

  • (String)

    the current value of pre_order_item_availability_date



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

def pre_order_item_availability_date
  @pre_order_item_availability_date
end

#re_order_indicatortrue/false

Returns the current value of re_order_indicator.

Returns:

  • (true/false)

    the current value of re_order_indicator



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

def re_order_indicator
  @re_order_indicator
end

Instance Method Details

#from_hash(hash) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ingenico/direct/sdk/domain/shopping_cart.rb', line 39

def from_hash(hash)
  super
  if hash.key? 'amountBreakdown'
    raise TypeError, "value '%s' is not an Array" % [hash['amountBreakdown']] unless hash['amountBreakdown'].is_a? Array
    @amount_breakdown = []
    hash['amountBreakdown'].each do |e|
      @amount_breakdown << Ingenico::Direct::SDK::Domain::AmountBreakdown.new_from_hash(e)
    end
  end
  if hash.key? 'giftCardPurchase'
    raise TypeError, "value '%s' is not a Hash" % [hash['giftCardPurchase']] unless hash['giftCardPurchase'].is_a? Hash
    @gift_card_purchase = Ingenico::Direct::SDK::Domain::GiftCardPurchase.new_from_hash(hash['giftCardPurchase'])
  end
  @is_pre_order = hash['isPreOrder'] if hash.key? 'isPreOrder'
  if hash.key? 'items'
    raise TypeError, "value '%s' is not an Array" % [hash['items']] unless hash['items'].is_a? Array
    @items = []
    hash['items'].each do |e|
      @items << Ingenico::Direct::SDK::Domain::LineItem.new_from_hash(e)
    end
  end
  @pre_order_item_availability_date = hash['preOrderItemAvailabilityDate'] if hash.key? 'preOrderItemAvailabilityDate'
  @re_order_indicator = hash['reOrderIndicator'] if hash.key? 'reOrderIndicator'
end

#to_hHash

Returns:

  • (Hash)


28
29
30
31
32
33
34
35
36
37
# File 'lib/ingenico/direct/sdk/domain/shopping_cart.rb', line 28

def to_h
  hash = super
  hash['amountBreakdown'] = @amount_breakdown.collect(&:to_h) if @amount_breakdown
  hash['giftCardPurchase'] = @gift_card_purchase.to_h if @gift_card_purchase
  hash['isPreOrder'] = @is_pre_order unless @is_pre_order.nil?
  hash['items'] = @items.collect(&:to_h) if @items
  hash['preOrderItemAvailabilityDate'] = @pre_order_item_availability_date unless @pre_order_item_availability_date.nil?
  hash['reOrderIndicator'] = @re_order_indicator unless @re_order_indicator.nil?
  hash
end