Class: Minfraud::Components::ShoppingCartItem

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

Overview

ShoppingCartItem corresponds to objects in the shopping_cart object of a minFraud request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(params = {}) ⇒ ShoppingCartItem

Returns a new instance of ShoppingCartItem.

Parameters:

  • params (Hash) (defaults to: {})

    Hash of parameters. Each key/value should correspond to one of the available attributes.



41
42
43
44
45
46
47
48
# File 'lib/minfraud/components/shopping_cart_item.rb', line 41

def initialize(params = {})
  @category = params[:category]
  @item_id  = params[:item_id]
  @quantity = params[:quantity]
  @price    = params[:price]

  validate
end

Instance Attribute Details

#categoryString?

The category of the item. This can also be a hashed value; see link.



17
18
19
# File 'lib/minfraud/components/shopping_cart_item.rb', line 17

def category
  @category
end

#item_idString?

The internal ID of the item. This can also be a hashed value; see link.



24
25
26
# File 'lib/minfraud/components/shopping_cart_item.rb', line 24

def item_id
  @item_id
end

#priceFloat?

The per-unit price of this item in the shopping cart. This should use the same currency as the order currency. The value must be at least 0 and at most 1e14 - 1.

Returns:

  • (Float, nil)


37
38
39
# File 'lib/minfraud/components/shopping_cart_item.rb', line 37

def price
  @price
end

#quantityInteger?

The quantity of the item in the shopping cart. The value must be at least 0, at most 10^13-1, and have no fractional part.

Returns:

  • (Integer, nil)


30
31
32
# File 'lib/minfraud/components/shopping_cart_item.rb', line 30

def quantity
  @quantity
end