# LoopsEx
Elixir SDK for the Loops API (loops.so)
## Configuration
Set your API key via environment variable:
```bash
export LOOPS_API_KEY="your_api_key"
```
Then add the following to your `config/config.exs`:
```elixir
config :loops_ex,
api_key: System.get_env("LOOPS_API_KEY")
```
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `loops_ex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:loops_ex, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/loops_ex>.
## Usage
Interact with the Loops API via the top-level module:
```elixir
# 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:
```bash
mix deps.get
mix test