LoopsEx

Elixir SDK for the Loops API (loops.so)

Configuration

Set your API key via environment variable:

export LOOPS_API_KEY="your_api_key"

Then add the following to your config/config.exs:

config :loops_ex,
  api_key: System.get_env("LOOPS_API_KEY")

Installation

If available in Hex, the package can be installed by adding loops_ex to your list of dependencies in mix.exs:

def deps do
  [
    {:loops_ex, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/loops_ex.

Usage

Interact with the Loops API via the top-level module:

# Test API key
LoopsEx.api_key_test()

# Contacts
LoopsEx.create_contact(%{"email" => "john@example.com"})
LoopsEx.update_contact(%{"email" => "john@example.com", "firstName" => "Jane"})
LoopsEx.find_contact(%{"email" => "john@example.com"})
LoopsEx.delete_contact(%{"userId" => "user_123"})

# Contact properties
LoopsEx.create_property(%{"name" => "planName", "type" => "string"})
LoopsEx.list_properties()

# Mailing lists
LoopsEx.list_mailing_lists()

# Events
LoopsEx.send_event(%{"email" => "john@example.com", "eventName" => "signup"})

# Transactional emails
LoopsEx.send_transactional(%{"email" => "john@example.com", "transactionalId" => "tid123", "dataVariables" => %{}})
LoopsEx.list_transactional(%{"perPage" => "20"})

Testing

Run the test suite:

mix deps.get
mix test