Peacemaker.Optin (Peacemaker v3.3.5-rc.7) View Source

This module interfaces with anything WealthFit Optin Related.

At the time of writing, we have 3 main optin domains for entry points:

  • Lead Magnet Optin
  • Expired Tripwire Offer Optin
  • Expired Intensive Offer Optin

Link to this section Summary

Functions

Creates a %Peacemaker.Optin{} changeset

Creates an Optin with an associated Segment record.

Attemps to find the Optin by the email first. If none exists, will create an %Optin{} record

Finds a Optin by en email

Link to this section Types

Link to this type

insert_raw_optin_response()

View Source

Specs

insert_raw_optin_response() :: Segment.t() | Ecto.Changeset.t()

Specs

t() :: %{first_name: String.t(), last_name: String.t(), email: String.t()}

Link to this section Functions

Link to this function

changeset(struct \\ %__MODULE__{}, attrs)

View Source

Creates a %Peacemaker.Optin{} changeset

Specs

create(t()) :: {atom(), insert_raw_optin_response()}

Creates an Optin with an associated Segment record.

This method should be the main entry point for creating optins within the WealthFit system.

This method returns an Optin record with the Segment record preloaded. We want to ensure that every Optin or Account has a Segment association. For more information on this pattern, check out the Ecto docs.

Example Usage:

  Peacemaker.Optin.create(%{
    first_name: "Bob",
    last_name: "Loblaw",
    email: "braddahman@wealthfit.com"
  })
Link to this function

find_or_create(optin_params)

View Source

Specs

find_or_create(%{
  first_name: String.t(),
  last_name: String.t(),
  email: String.t()
}) ::
  {atom(),
   %Peacemaker.Optin{
     __meta__: term(),
     allowed_intensives: term(),
     email: term(),
     first_name: term(),
     id: term(),
     last_name: term(),
     user_profile: term()
   }}

Attemps to find the Optin by the email first. If none exists, will create an %Optin{} record

Example Usage:

  Peacemaker.Optin.find_or_create(%{
    first_name: "Bob",
    last_name: "Loblaw",
    email: "braddahman@wealthfit.com"
  })

Specs

get_optin_by([{:email, String.t()}]) ::
  nil
  | %Peacemaker.Optin{
      __meta__: term(),
      allowed_intensives: term(),
      email: term(),
      first_name: term(),
      id: term(),
      last_name: term(),
      user_profile: term()
    }

Finds a Optin by en email

Link to this function

get_tracking_id(account)

View Source