Webhoox (Webhoox v0.3.1)

View Source

Package that makes it easy to deal with inbound webhooks.

Installation

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

def deps do
[
  {:webhoox, "~> 0.1.3"}
]
end

Example configuration for Mandrill with the Plug router

forward("_incoming",
  to: Webhoox,
  init_opts: [
    adapter: Webhoox.Adapter.Mandrill,
    adapter_opts: [
      secret: "i8PTcm8glMgsfaWf75bS1FQ",
      url: "http://example.com"
    ],
    handler: Example.Processor
  ]
)

Example configuration for Mandrill with the Phoenix router

forward("_incoming", Webhoox,
  adapter: Webhoox.Adapter.Mandrill,
  adapter_opts: [
    secret: "i8PTcm8glMgsfaWf75bS1FQ",
    url: "http://example.com"
  ],
  handler: Example.Processor
)

Example configuration for Mailgun with the Plug router

forward("_incoming",
  to: Webhoox,
  init_opts: [
    adapter: Webhoox.Adapter.Mailgun,
    adapter_opts: [
      api_key: "some-key"
    ],
    handler: Example.Processor
  ]
)

Example configuration for custom adapter

forward("_incoming", Webhoox,
  adapter: Your.Custom.Adapter,
  adapter_opts: [some_option: "some-option"],
  handler: Your.Processor
)

Example processor

defmodule Example.Processor do
  @behaviour Webhoox.Handler

  def process(%Webhoox.Webhook.Email{} = email) do
    IO.inspect(email)
  end
end