Home

Awesome

RavenxPusher

Hex pm Travis CI Hex.pm

RavenxPusher is a custom strategy for ravenx so we can send notifications through pusher in an easy and nice way.

Installation

To install this package, you need to add ravenx_pusher to your list of dependencies in mix.exs:

def deps do
  [{:ravenx_pusher, "~> 0.2.2"}]
end

And second you need to add it to the list of Ravenx strategies in the config in order for it to work:

config :ravenx, :strategies, [
  pusher: Ravenx.Strategy.Pusher
]

Configuration

** In order to use Pusher you'll need the following items from your apps dashboard so we can configure it properly:

Once we have them we can proceed.

As explained in the ravenx configuration section, we have different ways of configuring the adapters:

  1. Passing the options in the dispatch call:
iex> Ravenx.dispatch(:pusher, %{event: "my-event", data: "Data to send", channels: "my-channel"}, %{host: "localhost", port: 8080, app_id: "myAppId", app_key: "myAppKey", secret: "myAppSecret"})
  1. Specifying a configuration module in your application config:
config :ravenx,
  config: YourApp.RavenxConfig

And creating that module:

defmodule YourApp.RavenxConfig do
  def pusher(_payload) do
    %{
      app_id: "...",
      app_key: "...",
      secret: "...",
      host: "...",
      port: ... # 8080 for example
    }
  end
end

Note: the module should contain a function called as the strategy yopu are configuring, receiving the payload and returning a configuration Keyword list.

  1. Specifying the configuration directly on your application config file:
config :ravenx, :pusher,
  app_id: "...",
  app_key: "...",
  secret: "...",
  host: "...",
  port: ... # 8080 for example

If you want to know more about configuration options or ravenx itself go to their README.

Dispatching

To dispatch any notification through Pusher you need to pass a map (as the second parameter) to Ravenx.dispatch(:pusher, to_dispatch, opts \\ %{}) with the following keys:

License

Check LICENSE.