115 lines
2.9 KiB
Elixir
115 lines
2.9 KiB
Elixir
defmodule PolicyServiceWeb.Schemas.CarPolicy do
|
|
alias OpenApiSpex.Schema
|
|
|
|
defmodule ApplicantInfo do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ApplicantInfo",
|
|
type: :object,
|
|
required: [:name, :date_of_birth, :document_id],
|
|
properties: %{
|
|
name: %Schema{type: :string, example: "Juan Pérez"},
|
|
date_of_birth: %Schema{type: :string, format: :date, example: "1985-06-15"},
|
|
document_id: %Schema{type: :string, example: "V-12345678"}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule CarDetails do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "CarDetails",
|
|
type: :object,
|
|
required: [
|
|
:plate,
|
|
:make,
|
|
:model,
|
|
:year,
|
|
:car_value,
|
|
:use_type,
|
|
:car_type,
|
|
:chassis_number,
|
|
:engine_number
|
|
],
|
|
properties: %{
|
|
plate: %Schema{type: :string, example: "ABC-1234"},
|
|
make: %Schema{type: :string, example: "Toyota"},
|
|
model: %Schema{type: :string, example: "Corolla"},
|
|
year: %Schema{type: :integer, example: 2022},
|
|
car_value: %Schema{type: :number, example: 18000},
|
|
use_type: %Schema{
|
|
type: :string,
|
|
enum: ["private", "commercial", "bus", "taxi", "school"],
|
|
example: "private"
|
|
},
|
|
car_type: %Schema{
|
|
type: :string,
|
|
enum: [
|
|
"sedan",
|
|
"suv",
|
|
"hatchback",
|
|
"coupe",
|
|
"convertible",
|
|
"pickup",
|
|
"van",
|
|
"minivan",
|
|
"truck"
|
|
],
|
|
example: "sedan"
|
|
},
|
|
chassis_number: %Schema{type: :string, example: "9BWZZZ377VT004251"},
|
|
engine_number: %Schema{type: :string, example: "1NZ-FE-1234567"}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule Provider do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "Provider",
|
|
type: :object,
|
|
required: [:id, :email],
|
|
properties: %{
|
|
id: %Schema{type: :string, example: "provider-uuid"},
|
|
email: %Schema{type: :string, format: :email, example: "cotizaciones@aseguradora.com"}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteRequest do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteRequest",
|
|
type: :object,
|
|
required: [:applicant_info, :car_details, :selected_providers],
|
|
properties: %{
|
|
applicant_info: ApplicantInfo,
|
|
car_details: CarDetails,
|
|
selected_providers: %Schema{
|
|
type: :array,
|
|
items: Provider,
|
|
minItems: 1,
|
|
example: [%{id: "provider-uuid", email: "cotizaciones@aseguradora.com"}]
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteResponse",
|
|
type: :object,
|
|
properties: %{
|
|
application_id: %Schema{type: :string, example: "550e8400-e29b-41d4-a716-446655440000"},
|
|
status: %Schema{type: :string, example: "awaiting_quotes"}
|
|
}
|
|
})
|
|
end
|
|
end
|