Siftsciex v0.3.1 Siftsciex.Event.Payload.Item View Source

An item for a Sift Event

Link to this section Summary

Functions

Creates a Siftsciex.Event.Payload.Item.t/0 struct for a Sift Science Event payload

Link to this section Types

Link to this type data() View Source
data() :: %{
  optional(string_keys()) => String.t(),
  optional(int_keys()) => integer(),
  optional(list_keys()) => [String.t()]
}
Link to this type int_keys() View Source
int_keys() :: :price | :quantity
Link to this type list_keys() View Source
list_keys() :: :tags
Link to this type string_keys() View Source
string_keys() ::
  :item_id
  | :product_title
  | :currency_code
  | :upc
  | :sku
  | :isbn
  | :brand
  | :manufacturer
  | :category
  | :color
  | :size
Link to this type t() View Source
t() :: %Siftsciex.Event.Payload.Item{
  "$brand": Siftsciex.Event.Payload.payload_string(),
  "$category": Siftsciex.Event.Payload.payload_string(),
  "$color": Siftsciex.Event.Payload.payload_string(),
  "$currency_code": Siftsciex.Event.Payload.payload_string(),
  "$isbn": Siftsciex.Event.Payload.payload_string(),
  "$item_id": Siftsciex.Event.Payload.payload_string(),
  "$manufacturer": Siftsciex.Event.Payload.payload_string(),
  "$price": integer(),
  "$product_title": Siftsciex.Event.Payload.payload_string(),
  "$quantity": integer(),
  "$size": Siftsciex.Event.Payload.payload_string(),
  "$sku": Siftsciex.Event.Payload.payload_string(),
  "$tags": [String.t()],
  "$upc": Siftsciex.Event.Payload.payload_string()
}

Link to this section Functions

Creates a Siftsciex.Event.Payload.Item.t/0 struct for a Sift Science Event payload.

When creating a new Item the price will be converted based on the :currency config. For example if your currency config is set to :base and you are using “USD” then a price of 500 (5 dollars) will be converted to 5000000, this is because Sift Science expects the micros value relative to the base unit for the currency. This conversion is handled automatically for you.

Parameters

Examples

iex> Item.new(%{item_id: "8", product_title: "Title", currency_code: "USD", price: 30, quantity: 1})
%Item{"$item_id": "8", "$product_title": "Title", "$currency_code": "USD", "$price": 30000000, "$quantity": 1}

iex> Item.new(%{item_id: "8", tags: ["table", "dining"]})
%Item{"$item_id": "8", "$tags": ["table", "dining"]}

iex> Item.new([%{item_id: "8", quantity: 1}, %{item_id: "1", quantity: 30}])
[%Item{"$item_id": "8", "$quantity": 1}, %Item{"$item_id": "1", "$quantity": 30}]