consume commands correctly
All checks were successful
Build and Publish / build-release (push) Successful in 1m27s
All checks were successful
Build and Publish / build-release (push) Successful in 1m27s
This commit is contained in:
@@ -4,7 +4,7 @@ defmodule PolicyService.Consumers.QuoteTaskConsumer do
|
|||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias PolicyService.CommandedApp
|
alias PolicyService.CommandedApp
|
||||||
alias PolicyService.Commands.{CarPolicy, FirePolicy}
|
alias PolicyService.Commands.{CarPolicy, LifePolicy, FireStructurePolicy, FireContentsPolicy}
|
||||||
alias PolicyService.Aggregates.PolicyId
|
alias PolicyService.Aggregates.PolicyId
|
||||||
|
|
||||||
@exchange "workload_service.events.quote_task_completed"
|
@exchange "workload_service.events.quote_task_completed"
|
||||||
@@ -88,8 +88,46 @@ defmodule PolicyService.Consumers.QuoteTaskConsumer do
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
"fire" ->
|
"life" ->
|
||||||
%FirePolicy.RecordProviderQuote{
|
%LifePolicy.RecordProviderQuote{
|
||||||
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
|
recorded_by: recorded_by || "system",
|
||||||
|
provider_id: provider_id,
|
||||||
|
quote_id: quote_id,
|
||||||
|
valid_until: parse_date(valid_until),
|
||||||
|
plans:
|
||||||
|
Enum.map(
|
||||||
|
plans || [],
|
||||||
|
&%{
|
||||||
|
plan_id: &1["plan_id"],
|
||||||
|
name: &1["name"],
|
||||||
|
premium: &1["premium"],
|
||||||
|
coverage_details: &1["coverage_details"]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
"fire_structure" ->
|
||||||
|
%FireStructurePolicy.RecordProviderQuote{
|
||||||
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
|
recorded_by: recorded_by || "system",
|
||||||
|
provider_id: provider_id,
|
||||||
|
quote_id: quote_id,
|
||||||
|
valid_until: parse_date(valid_until),
|
||||||
|
plans:
|
||||||
|
Enum.map(
|
||||||
|
plans || [],
|
||||||
|
&%{
|
||||||
|
plan_id: &1["plan_id"],
|
||||||
|
name: &1["name"],
|
||||||
|
premium: &1["premium"],
|
||||||
|
coverage_details: &1["coverage_details"]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
"fire_contents" ->
|
||||||
|
%FireContentsPolicy.RecordProviderQuote{
|
||||||
id: PolicyId.new(org_id, policy_type, app_id),
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
recorded_by: recorded_by || "system",
|
recorded_by: recorded_by || "system",
|
||||||
provider_id: provider_id,
|
provider_id: provider_id,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ defmodule PolicyService.Consumers.SolicitationTaskConsumer do
|
|||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias PolicyService.CommandedApp
|
alias PolicyService.CommandedApp
|
||||||
alias PolicyService.Commands.CarPolicy
|
alias PolicyService.Commands.{CarPolicy, LifePolicy, FireStructurePolicy, FireContentsPolicy}
|
||||||
alias PolicyService.Aggregates.PolicyId
|
alias PolicyService.Aggregates.PolicyId
|
||||||
|
|
||||||
@exchange "workload_service.events.solicitation_task_completed"
|
@exchange "workload_service.events.solicitation_task_completed"
|
||||||
@@ -72,6 +72,36 @@ defmodule PolicyService.Consumers.SolicitationTaskConsumer do
|
|||||||
issued_at:
|
issued_at:
|
||||||
Map.get(submission, "issued_at") || DateTime.utc_now() |> DateTime.to_iso8601()
|
Map.get(submission, "issued_at") || DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"life" ->
|
||||||
|
%LifePolicy.RecordPolicyIssued{
|
||||||
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
|
provider_policy_number: Map.get(submission, "provider_policy_number"),
|
||||||
|
effective_date: Map.get(submission, "effective_date"),
|
||||||
|
expiry_date: Map.get(submission, "expiry_date"),
|
||||||
|
issued_at:
|
||||||
|
Map.get(submission, "issued_at") || DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
|
}
|
||||||
|
|
||||||
|
"fire_structure" ->
|
||||||
|
%FireStructurePolicy.RecordPolicyIssued{
|
||||||
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
|
provider_policy_number: Map.get(submission, "provider_policy_number"),
|
||||||
|
effective_date: Map.get(submission, "effective_date"),
|
||||||
|
expiry_date: Map.get(submission, "expiry_date"),
|
||||||
|
issued_at:
|
||||||
|
Map.get(submission, "issued_at") || DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
|
}
|
||||||
|
|
||||||
|
"fire_contents" ->
|
||||||
|
%FireContentsPolicy.RecordPolicyIssued{
|
||||||
|
id: PolicyId.new(org_id, policy_type, app_id),
|
||||||
|
provider_policy_number: Map.get(submission, "provider_policy_number"),
|
||||||
|
effective_date: Map.get(submission, "effective_date"),
|
||||||
|
expiry_date: Map.get(submission, "expiry_date"),
|
||||||
|
issued_at:
|
||||||
|
Map.get(submission, "issued_at") || DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
case CommandedApp.dispatch(cmd, consistency: :strong) do
|
case CommandedApp.dispatch(cmd, consistency: :strong) do
|
||||||
|
|||||||
Reference in New Issue
Block a user