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

A Promotion represents just that in Sift Science. Things like referrals, coupons, free trials etc are considered promotions.

Link to this section Summary

Functions

Creates a new Promotion record for a Sift Science Event

Link to this section Types

Link to this type data() View Source
data() :: %{
  optional(string_key()) => String.t(),
  optional(:status) => status(),
  optional(:discount) => Siftsciex.Event.Payload.Discount.data(),
  optional(:credit_point) => Siftsciex.Event.Payload.CreditPoint.data()
}
Link to this type status() View Source
status() :: :success | :failure
Link to this type string_key() View Source
string_key() ::
  :promotion_id | :failure_reason | :description | :referrer_user_id
Link to this type t() View Source
t() :: %Siftsciex.Event.Payload.Promotion{
  "$credit_point": :empty | Siftsciex.Event.Payload.CreditPoint.t(),
  "$description": Siftsciex.Event.Payload.payload_string(),
  "$discount": :empty | Siftsciex.Event.Payload.Discount.t(),
  "$failure_reason": Siftsciex.Event.Payload.payload_string(),
  "$promotion_id": Siftsciex.Event.Payload.payload_string(),
  "$referrer_user_id": Siftsciex.Event.Payload.payload_string(),
  "$status": Siftsciex.Event.Payload.payload_string()
}

Link to this section Functions

Creates a new Promotion record for a Sift Science Event.

Parameters

  • promotion_data: The data for the promotion being reported to Sift Science, there are a few attributes available.

    • :promotion_id - A string idenditying the promotion
    • :success - Whether the promotion event indicates success or failure (:success, :failure)
    • :failure_reason - The reason for failure (String.t)
    • :description - A description of the failure (String.t)
    • :referrer_user_id - If the promotion had a referrer (String.t)
    • :discount - Any applicable discount for the promotion (Siftsciex.Body.Event.Discount.data)
    • :credit_point - Any applicable credit for the promotion (Siftsciex.Body.Event.CreditPoint.data)

Examples

iex> Promotion.new(%{promotion_id: "promo", status: :success})
%Promotion{"$promotion_id": "promo", "$status": "$success"}

iex> Promotion.new([%{promotion_id: "promo", status: :success}, %{promotion_id: "promo2", status: :success}])
[%Promotion{"$promotion_id": "promo", "$status": "$success"}, %Promotion{"$promotion_id": "promo2", "$status": "$success"}]

iex> Promotion.new(%{promotion_id: "promo", discount: %{percentage_off: 0.25}})
%Promotion{"$promotion_id": "promo", "$discount": %Siftsciex.Event.Payload.Discount{"$percentage_off": 0.25}}

iex> Promotion.new(%{promotion_id: "promo", credit_point: %{amount: 33, credit_point_type: "Things"}})
%Promotion{"$promotion_id": "promo", "$credit_point": %Siftsciex.Event.Payload.CreditPoint{"$amount": 33, "$credit_point_type": "Things"}}

iex> Promotion.new(%{promotion_id: "promo", credit_point: %{amount: 1, credit_point_type: "Thing"}, discount: %{percentage_off: 0.1}})
%Promotion{"$promotion_id": "promo", "$credit_point": %Siftsciex.Event.Payload.CreditPoint{"$amount": 1, "$credit_point_type": "Thing"}, "$discount": %Siftsciex.Event.Payload.Discount{"$percentage_off": 0.1}}