cover/Elixir.WalletTransfers.Events.TransferCompleted.html

1 defmodule WalletTransfers.Events.TransferCompleted do
2 @moduledoc "Emitted when a reserved transfer is successfully completed."
3 @behaviour WalletEvents.DomainEvent
4
5 @impl true
6 6 def event_name, do: "TransferCompleted.v1"
7
8 @impl true
9 6 def event_version, do: 1
10
11 @doc "Builds the domain event map."
12
:-(
def build(transfer_id, user_id, opts \\ []) do
13 6 %{
14 event_id: WalletSharedKernel.Correlation.new_request_id(),
15 event_name: event_name(),
16 event_version: event_version(),
17 aggregate_id: transfer_id,
18 correlation_id:
19 Keyword.get(opts, :correlation_id, WalletSharedKernel.Correlation.new_correlation_id()),
20 occurred_at: DateTime.utc_now(),
21 payload: %{
22 transfer_id: transfer_id,
23 user_id: user_id,
24 amount: Keyword.get(opts, :amount),
25 currency: Keyword.get(opts, :currency),
26 completed_at: Keyword.get(opts, :completed_at)
27 }
28 }
29 end
30 end
Line Hits Source