View Source ArkeServer.Swoosh.Adapters.OneSignal (arke_server v0.3.14)

An adapter that sends email using the OneSignal API.

For reference: OneSignal API docs

This adapter requires an API Client. Swoosh comes with Hackney and Finch out of the box. See the installation section for details.

Dependency

OneSignal adapter requires Plug to work properly.

Configuration options

  • :api_key - the API key used with Mailgun
  • :domain - the domain you will be sending emails from.
  • :app_id - the domain you will be sending emails from.
  • :base_url - the url to use as the API endpoint. use https://onesignal.com/api/v1/notifications

Example

# config/config.exs
config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.OneSignal,
  api_key: "my-api-key",
  domain: "mydomain.com"

# lib/sample/mailer.ex
defmodule Sample.Mailer do
  use Swoosh.Mailer, otp_app: :sample
end

Using with provider options

import Swoosh.Email

new()
|> from({"T Stark", "tony.stark@example.com"})
|> to({"Steve Rogers", "steve.rogers@example.com"})
|> to("wasp.avengers@example.com")
|> reply_to("office.avengers@example.com")
|> cc({"Bruce Banner", "hulk.smash@example.com"})
|> cc("thor.odinson@example.com")
|> bcc({"Clinton Francis Barton", "hawk.eye@example.com"})
|> bcc("beast.avengers@example.com")
|> subject("Hello, Avengers!")
|> html_body("<h1>Hello</h1>")
|> text_body("Hello")
|> put_provider_option(:template_id, "Template mail")
|> put_provider_option(:custom_data, %{"key" => "value"})

Provider options

  • :custom_data (map) - used to add custom data to email

  • :template_id (string) - template, name of template created at OneSignal

Custom headers

Headers added via Email.header/3 will be translated to (h:) values that Mailgun recognizes.

Summary

Functions

Callback implementation for Swoosh.Adapter.validate_config/1.

Callback implementation for Swoosh.Adapter.validate_dependency/0.