class Minfraud::Components::ShoppingCartItem

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

@see dev.maxmind.com/minfraud/#Shopping_Cart_Item

Attributes

category[RW]

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

@see dev.maxmind.com/minfraud/#cart-hashing

@return [String, nil]

item_id[RW]

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

@see dev.maxmind.com/minfraud/#cart-hashing

@return [String, nil]

price[RW]

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.

@return [Float, nil]

quantity[RW]

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.

@return [Integer, nil]

Public Class Methods

new(params = {}) click to toggle source

@param params [Hash] Hash of parameters. Each key/value should

correspond to one of the available attributes.
# 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

Private Instance Methods

validate() click to toggle source
# File lib/minfraud/components/shopping_cart_item.rb, line 52
def validate
  return if !Minfraud.enable_validation

  validate_string('category', 255, @category)
  validate_string('item_id', 255, @item_id)
  validate_nonnegative_integer('quantity', @quantity)
  validate_nonnegative_number('price', @price)
end