Some checks failed
Build and Publish / build-release (push) Failing after 35s
107 lines
2.1 KiB
Elixir
107 lines
2.1 KiB
Elixir
defmodule PolicyService.Events.Policy do
|
|
@moduledoc """
|
|
Policy domain events.
|
|
Contains helpers for common event functionality.
|
|
"""
|
|
|
|
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
|
|
|
|
defmodule PolicyApplicationSubmitted do
|
|
use PolicyService.Events.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:submitted_by,
|
|
:applicant_info,
|
|
:policy_details,
|
|
:selected_providers,
|
|
:submitted_at
|
|
]
|
|
end
|
|
|
|
defmodule QuoteRequestSent do
|
|
use PolicyService.Events.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:provider_id,
|
|
:provider_email,
|
|
:applicant_info,
|
|
:policy_details,
|
|
:requested_at
|
|
]
|
|
end
|
|
|
|
defmodule ProviderQuoteReceived do
|
|
use PolicyService.Events.Policy
|
|
@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.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [:id, :quote_count]
|
|
end
|
|
|
|
defmodule QuoteAccepted do
|
|
use PolicyService.Events.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:accepted_by,
|
|
:quote,
|
|
:plan,
|
|
:provider,
|
|
:accepted_at
|
|
]
|
|
end
|
|
|
|
defmodule SolicitationSent do
|
|
use PolicyService.Events.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:solicitation_id,
|
|
:provider_id,
|
|
:template_id,
|
|
:s3_key,
|
|
:sent_at
|
|
]
|
|
end
|
|
|
|
defmodule PolicyIssued do
|
|
use PolicyService.Events.Policy
|
|
@derive Jason.Encoder
|
|
defstruct [
|
|
:id,
|
|
:policy_number,
|
|
:effective_date,
|
|
:expiry_date,
|
|
:issued_at
|
|
]
|
|
end
|
|
end
|