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
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
.
emit_sync(binary(), map()) :: BtrzWebhooksEmitter.SQS.emit_sync_response()
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}