All checks were successful
Build and Publish / build-release (push) Successful in 1m31s
236 lines
6.5 KiB
Elixir
236 lines
6.5 KiB
Elixir
defmodule WorkloadServiceWeb.Schemas.Task do
|
|
alias OpenApiSpex.Schema
|
|
|
|
defmodule PaginationMeta do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "PaginationMeta",
|
|
type: :object,
|
|
properties: %{
|
|
total_count: %Schema{type: :integer},
|
|
total_pages: %Schema{type: :integer},
|
|
current_page: %Schema{type: :integer},
|
|
page_size: %Schema{type: :integer},
|
|
has_next: %Schema{type: :boolean},
|
|
has_prev: %Schema{type: :boolean}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule Plan do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "Plan",
|
|
type: :object,
|
|
required: [:plan_id, :name, :premium, :coverage_details],
|
|
properties: %{
|
|
plan_id: %Schema{type: :string},
|
|
name: %Schema{type: :string},
|
|
premium: %Schema{type: :number, exclusiveMinimum: 0},
|
|
coverage_details: %Schema{type: :object, additionalProperties: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteTaskInfo do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteTaskInfo",
|
|
type: :object,
|
|
required: [:provider_id, :applicant_info, :policy_details],
|
|
properties: %{
|
|
provider_id: %Schema{type: :string},
|
|
applicant_info: %Schema{type: :object, additionalProperties: true},
|
|
policy_details: %Schema{type: :object, additionalProperties: true},
|
|
provider_email: %Schema{type: :string, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule SolicitationTaskInfo do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "SolicitationTaskInfo",
|
|
type: :object,
|
|
required: [:provider_id, :plan_id, :plan_name, :premium, :coverage_details],
|
|
properties: %{
|
|
provider_id: %Schema{type: :string},
|
|
plan_id: %Schema{type: :string},
|
|
plan_name: %Schema{type: :string},
|
|
premium: %Schema{type: :number},
|
|
coverage_details: %Schema{type: :object, additionalProperties: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteSubmissionDetail do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteSubmissionDetail",
|
|
type: :object,
|
|
required: [:quote_id, :valid_until, :plans],
|
|
properties: %{
|
|
quote_id: %Schema{type: :string},
|
|
valid_until: %Schema{type: :string, format: :date},
|
|
plans: %Schema{type: :array, items: Plan, minItems: 1},
|
|
document_data: %Schema{type: :object, additionalProperties: true, nullable: true},
|
|
document_urls: %Schema{type: :array, items: %Schema{type: :string}, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule SolicitationSubmissionDetail do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "SolicitationSubmissionDetail",
|
|
type: :object,
|
|
required: [:provider_policy_number, :effective_date, :expiry_date],
|
|
properties: %{
|
|
provider_policy_number: %Schema{type: :string},
|
|
effective_date: %Schema{type: :string, format: :date},
|
|
expiry_date: %Schema{type: :string, format: :date}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteSubmission do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteSubmission",
|
|
type: :object,
|
|
required: [:quote_id, :recorded_by, :valid_until, :plans],
|
|
properties: %{
|
|
quote_id: %Schema{type: :string},
|
|
recorded_by: %Schema{type: :string},
|
|
valid_until: %Schema{type: :string, format: :date},
|
|
plans: %Schema{type: :array, items: Plan, minItems: 1},
|
|
document_data: %Schema{type: :object, additionalProperties: true, nullable: true},
|
|
document_urls: %Schema{type: :array, items: %Schema{type: :string}, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule SolicitationSubmission do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "SolicitationSubmission",
|
|
type: :object,
|
|
required: [:provider_policy_number, :effective_date, :expiry_date],
|
|
properties: %{
|
|
provider_policy_number: %Schema{type: :string},
|
|
effective_date: %Schema{type: :string, format: :date},
|
|
expiry_date: %Schema{type: :string, format: :date}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule TaskSummary do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "TaskSummary",
|
|
type: :object,
|
|
properties: %{
|
|
id: %Schema{type: :string},
|
|
org_id: %Schema{type: :string},
|
|
application_id: %Schema{type: :string},
|
|
policy_type: %Schema{type: :string, enum: ["car", "life", "fire"]},
|
|
task_info: %Schema{oneOf: [QuoteTaskInfo, SolicitationTaskInfo]},
|
|
status: %Schema{type: :string, enum: ["created", "draft", "approved", "completed"]},
|
|
created_at: %Schema{type: :string, format: :"date-time"}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule TaskDetail do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "TaskDetail",
|
|
type: :object,
|
|
properties: %{
|
|
id: %Schema{type: :string},
|
|
org_id: %Schema{type: :string},
|
|
application_id: %Schema{type: :string},
|
|
policy_type: %Schema{type: :string, enum: ["car", "life", "fire"]},
|
|
task_info: %Schema{oneOf: [QuoteTaskInfo, SolicitationTaskInfo]},
|
|
submission: %Schema{
|
|
oneOf: [QuoteSubmissionDetail, SolicitationSubmissionDetail],
|
|
nullable: true
|
|
},
|
|
attachments: %Schema{type: :array, items: %Schema{type: :string}},
|
|
status: %Schema{type: :string, enum: ["created", "draft", "approved", "completed"]},
|
|
created_at: %Schema{type: :string, format: :"date-time"},
|
|
updated_at: %Schema{type: :string, format: :"date-time"}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule SubmitRequest do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "SubmitRequest",
|
|
type: :object,
|
|
anyOf: [QuoteSubmission, SolicitationSubmission]
|
|
})
|
|
end
|
|
|
|
defmodule CompleteRequest do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "CompleteRequest",
|
|
type: :object,
|
|
properties: %{
|
|
completed_by: %Schema{type: :string}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule TaskListResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "TaskListResponse",
|
|
type: :object,
|
|
properties: %{
|
|
data: %Schema{type: :array, items: TaskSummary},
|
|
meta: PaginationMeta
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule TaskDetailResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "TaskDetailResponse",
|
|
type: :object,
|
|
properties: %{
|
|
data: TaskDetail
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule ErrorResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ErrorResponse",
|
|
type: :object,
|
|
properties: %{
|
|
error: %Schema{type: :string}
|
|
}
|
|
})
|
|
end
|
|
end
|