class Ingenico::Direct::SDK::Domain::ShoppingCart

@attr [Array<Ingenico::Direct::SDK::Domain::AmountBreakdown>] amount_breakdown @attr [Ingenico::Direct::SDK::Domain::GiftCardPurchase] gift_card_purchase @attr [true/false] is_pre_order @attr [Array<Ingenico::Direct::SDK::Domain::LineItem>] items @attr [String] pre_order_item_availability_date @attr [true/false] re_order_indicator

Attributes

amount_breakdown[RW]
gift_card_purchase[RW]
is_pre_order[RW]
items[RW]
pre_order_item_availability_date[RW]
re_order_indicator[RW]

Public Instance Methods

from_hash(hash) click to toggle source
# 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_h() click to toggle source

@return (Hash)

Calls superclass method Ingenico::Direct::SDK::DataObject#to_h
# 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