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

A discount for a Sift Event

Link to this section Summary

Functions

Create a new Discount type for a Sift Science Event payload

Link to this section Types

Link to this type data() View Source
data() :: %{
  optional(:currency_code) => String.t(),
  optional(numeric_key()) => numeric()
}
Link to this type numeric() View Source
numeric() :: integer() | float()
Link to this type numeric_key() View Source
numeric_key() :: :percentage_off | :amount | :minimum_purchase_amount
Link to this type t() View Source
t() :: %Siftsciex.Event.Payload.Discount{
  "$amount": Siftsciex.Event.Payload.payload_int(),
  "$currency_code": Siftsciex.Event.Payload.payload_string(),
  "$minimum_purchase_amount": Siftsciex.Event.Payload.payload_int(),
  "$percentage_off": Siftsciex.Event.Payload.payload_float()
}

Link to this section Functions

Create a new Discount type for a Sift Science Event payload.

Parameters

  • data: A map defining the details of the discount, there are four keys which are legal for a discount:

    • :percentage_off - A float representing the discount as a percentage.
    • :amount - The total amount of the discount, this value will be converted to micros automatically (see Siftsciex.Currency).
    • :currency_code - The currency in which the discount is being measured.
    • :minimum_purchase_amount - The minimum purchase amount before the discount applies.

Examples

iex> Discount.new(%{percentage_off: 0.3, amount: 3, currency_code: "USD"})
%Discount{"$percentage_off": 0.3, "$amount": 3000000, "$currency_code": "USD"}

iex> Discount.new(%{percentage_off: 0.1, currency_code: "USD", amount: 100, minimum_purchase_amount: 50})
%Discount{"$percentage_off": 0.1, "$currency_code": "USD", "$amount": 100000000, "$minimum_purchase_amount": 50000000}