Class: Minfraud::Components::ShoppingCart

Inherits:
Base
  • Object
show all
Defined in:
lib/minfraud/components/shopping_cart.rb

Overview

ShoppingCart corresponds to the shopping_cart object of a minFraud request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = []) ⇒ ShoppingCart

Returns a new instance of ShoppingCart.

Parameters:

  • params (Array) (defaults to: [])

    Array of shopping cart items. You may provide each item as either a Hash where each key is a symbol corresponding to an item's field, or as a Minfraud:::Components::ShoppingCartItem object.


19
20
21
# File 'lib/minfraud/components/shopping_cart.rb', line 19

def initialize(params = [])
  @items = params.map(&method(:resolve))
end

Instance Attribute Details

#itemsArray<Minfraud::Components::ShoppingCartItem>

An array of Minfraud::Components::ShoppingCartItem instances.


13
14
15
# File 'lib/minfraud/components/shopping_cart.rb', line 13

def items
  @items
end

Instance Method Details

#to_json(*_args) ⇒ Array

A JSON representation of Minfraud::Components::ShoppingCart items.

Returns:

  • (Array)

26
27
28
# File 'lib/minfraud/components/shopping_cart.rb', line 26

def to_json(*_args)
  @items.map(&:to_json)
end