All checks were successful
Build and Publish / build-release (push) Successful in 4m46s
229 lines
6.2 KiB
Elixir
229 lines
6.2 KiB
Elixir
defmodule ProviderServiceWeb.Schemas.Provider 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 TemplateField do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "TemplateField",
|
|
type: :object,
|
|
properties: %{
|
|
field: %Schema{type: :string, example: "beneficiary_name"},
|
|
label: %Schema{type: :string, example: "Beneficiary Name"},
|
|
type: %Schema{type: :string, enum: ["string", "date", "number", "select", "boolean"]},
|
|
required: %Schema{type: :boolean},
|
|
options: %Schema{type: :array, items: %Schema{type: :string}, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule Template do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "Template",
|
|
type: :object,
|
|
properties: %{
|
|
template_id: %Schema{type: :string, format: :uuid},
|
|
policy_type: %Schema{type: :string, enum: ["car", "life", "fire"]},
|
|
client_type: %Schema{type: :string, enum: ["natural", "juridico"]},
|
|
s3_key: %Schema{type: :string},
|
|
version: %Schema{type: :integer},
|
|
fields: %Schema{type: :array, items: TemplateField},
|
|
active: %Schema{type: :boolean}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule RegisterProvider do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "RegisterProvider",
|
|
type: :object,
|
|
required: [:provider_id, :name],
|
|
properties: %{
|
|
provider_id: %Schema{
|
|
type: :string,
|
|
pattern: "^[a-zA-Z0-9]+$",
|
|
description: "Alphanumeric ID for the provider"
|
|
},
|
|
name: %Schema{type: :string, example: "Seguros ABC"},
|
|
email: %Schema{type: :string, format: :email},
|
|
phone: %Schema{type: :string},
|
|
contact_name: %Schema{type: :string},
|
|
ruc: %Schema{type: :string},
|
|
address: %Schema{type: :string}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule UpdateProvider do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "UpdateProvider",
|
|
type: :object,
|
|
properties: %{
|
|
name: %Schema{type: :string},
|
|
email: %Schema{type: :string, format: :email},
|
|
phone: %Schema{type: :string},
|
|
contact_name: %Schema{type: :string},
|
|
ruc: %Schema{type: :string},
|
|
address: %Schema{type: :string}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule UploadTemplateRequest do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "UploadTemplateRequest",
|
|
type: :object,
|
|
required: [:file, :policy_type, :client_type],
|
|
properties: %{
|
|
file: %Schema{
|
|
type: :string,
|
|
format: :binary,
|
|
description: "Fillable PDF (AcroForm)"
|
|
},
|
|
policy_type: %Schema{
|
|
type: :string,
|
|
enum: ["car", "life", "fire"],
|
|
description: "Policy type this template applies to"
|
|
},
|
|
client_type: %Schema{
|
|
type: :string,
|
|
enum: ["natural", "juridico"],
|
|
description: "Client type this template applies to"
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule UploadTemplateResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "UploadTemplateResponse",
|
|
type: :object,
|
|
properties: %{
|
|
template_id: %Schema{type: :string, format: :uuid},
|
|
s3_key: %Schema{type: :string},
|
|
fields: %Schema{type: :array, items: TemplateField}
|
|
}
|
|
})
|
|
end
|
|
|
|
# templates: %{ policy_type => %{ client_type => [Template] } }
|
|
# default_templates: %{ policy_type => %{ client_type => template_id } }
|
|
|
|
defmodule ClientTypeTemplates do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ClientTypeTemplates",
|
|
type: :object,
|
|
description: "Map of client_type (natural | juridico) to list of templates",
|
|
properties: %{
|
|
natural: %Schema{type: :array, items: Template, nullable: true},
|
|
juridico: %Schema{type: :array, items: Template, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule ClientTypeDefaults do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ClientTypeDefaults",
|
|
type: :object,
|
|
description: "Map of client_type (natural | juridico) to default template_id",
|
|
properties: %{
|
|
natural: %Schema{type: :string, format: :uuid, nullable: true},
|
|
juridico: %Schema{type: :string, format: :uuid, nullable: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule ProviderData do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ProviderData",
|
|
type: :object,
|
|
properties: %{
|
|
provider_id: %Schema{type: :string, format: :uuid},
|
|
name: %Schema{type: :string},
|
|
email: %Schema{type: :string},
|
|
phone: %Schema{type: :string},
|
|
contact_name: %Schema{type: :string},
|
|
ruc: %Schema{type: :string},
|
|
address: %Schema{type: :string},
|
|
active: %Schema{type: :boolean},
|
|
templates: %Schema{
|
|
type: :object,
|
|
description: "Map of policy_type (car | life | fire) to client_type map of templates",
|
|
properties: %{
|
|
car: ClientTypeTemplates,
|
|
life: ClientTypeTemplates,
|
|
fire: ClientTypeTemplates
|
|
}
|
|
},
|
|
default_templates: %Schema{
|
|
type: :object,
|
|
description: "Map of policy_type to client_type to default template_id",
|
|
properties: %{
|
|
car: ClientTypeDefaults,
|
|
life: ClientTypeDefaults,
|
|
fire: ClientTypeDefaults
|
|
}
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule ProviderResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ProviderResponse",
|
|
type: :object,
|
|
properties: %{
|
|
data: ProviderData
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule ProviderListResponse do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "ProviderListResponse",
|
|
type: :object,
|
|
properties: %{
|
|
data: %Schema{type: :array, items: ProviderData},
|
|
meta: PaginationMeta
|
|
}
|
|
})
|
|
end
|
|
end
|