BtrzWebhooksEmitter v0.3.0 BtrzWebhooksEmitter View Source

BtrzWebhooksEmitter emits webhooks to SQS for the Betterez platform.

This module has the API to send messages asynchrounously to the BtrzWebhooksEmitter.SQS.

You will have to set these ENV vars:

  • AWS_SERVICE_KEY
  • AWS_SERVICE_SECRET
  • SQS_QUEUE_URL

You can set SQS_QUEUE_URL in your config:

config :btrz_ex_webhooks_emitter, queue_url: "id/name"

If one of them is missing the messages will be ignored.

How to use

You have to send a map with the following required (string) keys:

  • “provider_id”
  • “api_key”
  • “data”

Optional keys:

  • “url”
message = %{
  "provider_id" => "123",
  "api_key" => "PROVIDER_PUBLIC_KEY",
  "data" => %{"foo" => "bar"}
}
BtrzWebhooksEmitter.emit("transaction.created", message)

Link to this section Summary

Functions

Returns the message map

Builds and sends messages asynchrounously to the BtrzWebhooksEmitter.SQS If there is a validation error in your attrs it will return :error and log the error, otherwise always :ok

Builds and sends messages synchrounously to the BtrzWebhooksEmitter.SQS For particular use, try always to use emit/2 if possible

Link to this section Functions

Link to this function build_message(event_name, attrs) View Source
build_message(binary(), map()) :: map()

Returns the message map.

Link to this function emit(event_name, attrs) View Source
emit(binary(), map()) :: :ok | :error

Builds and sends messages asynchrounously to the BtrzWebhooksEmitter.SQS If there is a validation error in your attrs it will return :error and log the error, otherwise always :ok.

Builds and sends messages synchrounously to the BtrzWebhooksEmitter.SQS For particular use, try always to use emit/2 if possible.

Returns {:ok, term} or {:error, term}