All checks were successful
Build and Publish / build-release (push) Successful in 1m38s
97 lines
2.0 KiB
Elixir
97 lines
2.0 KiB
Elixir
defmodule PolicyService.Events do
|
|
@moduledoc """
|
|
Events macro for adding JsonDecoder to domain events.
|
|
"""
|
|
|
|
alias PolicyService.Aggregates.PolicyId
|
|
|
|
defmacro __using__(_opts) do
|
|
quote do
|
|
defimpl Commanded.Serialization.JsonDecoder do
|
|
def decode(
|
|
%{id: %{org_id: org_id, policy_type: policy_type, application_id: application_id}} =
|
|
event
|
|
) do
|
|
%{event | id: PolicyId.new(org_id, policy_type, application_id)}
|
|
end
|
|
|
|
def decode(event), do: event
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
defmodule PolicyService.Events.Policy do
|
|
@moduledoc """
|
|
Policy domain events.
|
|
"""
|
|
|
|
defmodule PolicyApplicationSubmitted do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:submitted_by,
|
|
:insured,
|
|
:buyer,
|
|
:policy_details,
|
|
:selected_providers,
|
|
:submitted_at
|
|
]
|
|
end
|
|
|
|
defmodule QuoteRequestSent do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:provider_id,
|
|
:provider_email,
|
|
:insured,
|
|
:buyer,
|
|
:policy_details,
|
|
:requested_at
|
|
]
|
|
end
|
|
|
|
defmodule ProviderQuoteReceived do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:recorded_by,
|
|
:provider_id,
|
|
:quote_id,
|
|
:premium,
|
|
:coverage_details,
|
|
:valid_until,
|
|
:plans,
|
|
:received_at
|
|
]
|
|
end
|
|
|
|
defmodule AllQuotesReceived do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [:id, :quote_count]
|
|
end
|
|
|
|
defmodule QuoteAccepted do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [:id, :accepted_by, :quote, :plan, :provider]
|
|
end
|
|
|
|
defmodule SolicitationRequestSent do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [:id, :plan, :provider_id]
|
|
end
|
|
|
|
defmodule PolicyIssued do
|
|
use PolicyService.Events
|
|
@derive Jason.Encoder
|
|
defstruct [:id, :provider_policy_number, :effective_date, :expiry_date, :issued_at]
|
|
end
|
|
end
|