| 1 |
|
defmodule WalletSettlement.Events.SettlementBatchCompleted do |
| 2 |
|
@moduledoc "Emitted when a settlement batch reaches :completed or :partial." |
| 3 |
|
@behaviour WalletEvents.DomainEvent |
| 4 |
|
|
| 5 |
|
@impl true |
| 6 |
4 |
def event_name, do: "SettlementBatchCompleted.v1" |
| 7 |
|
@impl true |
| 8 |
4 |
def event_version, do: 1 |
| 9 |
|
|
| 10 |
:-( |
def build(batch_id, opts \\ []) do |
| 11 |
4 |
%{ |
| 12 |
|
event_id: WalletSharedKernel.Correlation.new_request_id(), |
| 13 |
|
event_name: event_name(), |
| 14 |
|
event_version: event_version(), |
| 15 |
|
aggregate_id: batch_id, |
| 16 |
|
correlation_id: Keyword.get(opts, :correlation_id, WalletSharedKernel.Correlation.new_correlation_id()), |
| 17 |
|
occurred_at: DateTime.utc_now(), |
| 18 |
|
payload: %{ |
| 19 |
|
batch_id: batch_id, |
| 20 |
|
status: Keyword.get(opts, :status, :completed), |
| 21 |
|
settled_count: Keyword.get(opts, :settled_count, 0), |
| 22 |
|
failed_count: Keyword.get(opts, :failed_count, 0), |
| 23 |
|
exception_count: Keyword.get(opts, :exception_count, 0) |
| 24 |
|
} |
| 25 |
|
} |
| 26 |
|
end |
| 27 |
|
end |