| 1 |
|
defmodule WalletLimitsFees.Events.LimitPolicyUpdated do |
| 2 |
|
@moduledoc "Emitted when a limit policy is created or updated." |
| 3 |
|
@behaviour WalletEvents.DomainEvent |
| 4 |
|
|
| 5 |
|
@impl true |
| 6 |
7 |
def event_name, do: "LimitPolicyUpdated.v1" |
| 7 |
|
|
| 8 |
|
@impl true |
| 9 |
7 |
def event_version, do: 1 |
| 10 |
|
|
| 11 |
|
@doc "Builds the domain event map." |
| 12 |
:-( |
def build(policy_id, tier, currency, opts \\ []) do |
| 13 |
7 |
%{ |
| 14 |
|
event_id: WalletSharedKernel.Correlation.new_request_id(), |
| 15 |
|
event_name: event_name(), |
| 16 |
|
event_version: event_version(), |
| 17 |
|
aggregate_id: policy_id, |
| 18 |
|
correlation_id: |
| 19 |
|
Keyword.get(opts, :correlation_id, WalletSharedKernel.Correlation.new_correlation_id()), |
| 20 |
|
occurred_at: DateTime.utc_now(), |
| 21 |
|
payload: %{ |
| 22 |
|
policy_id: policy_id, |
| 23 |
|
tier: tier, |
| 24 |
|
currency: currency, |
| 25 |
|
version: Keyword.get(opts, :version, 1) |
| 26 |
|
} |
| 27 |
|
} |
| 28 |
|
end |
| 29 |
|
end |