init commit
Some checks failed
Build and Publish / build-release (push) Failing after 1s

This commit is contained in:
2026-04-15 16:20:22 -05:00
parent 072dbf6e66
commit b1b1c21e4e
28 changed files with 822 additions and 194 deletions

View File

@@ -1,37 +1,140 @@
defmodule CustomerServiceWeb.Schemas do
defmodule CustomerResponse do
defmodule CustomerServiceWeb.Schemas.Customer do
alias OpenApiSpex.Schema
defmodule PaginationMeta do
require OpenApiSpex
alias OpenApiSpex.Schema
OpenApiSpex.schema(%{
title: "Customer",
title: "PaginationMeta",
type: :object,
properties: %{
id: %Schema{type: :string, format: :uuid},
first_name: %Schema{type: :string},
last_name: %Schema{type: :string},
birth_date: %Schema{type: :string, format: :date},
gender: %Schema{type: :string},
email: %Schema{type: :string, format: :email},
phone: %Schema{type: :string}
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 CreateCustomerRequest do
defmodule IndividualCustomerData do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "IndividualCustomer",
type: :object,
properties: %{
id: %Schema{type: :string, format: :uuid},
customer_type: %Schema{type: :string, enum: ["individual"]},
first_name: %Schema{type: :string},
last_name: %Schema{type: :string},
email: %Schema{type: :string, format: :email},
phone: %Schema{type: :string},
birth_date: %Schema{type: :string, format: :date},
gender: %Schema{type: :string},
document_id: %Schema{type: :string}
}
})
end
defmodule CorporateCustomerData do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "CorporateCustomer",
type: :object,
properties: %{
id: %Schema{type: :string, format: :uuid},
customer_type: %Schema{type: :string, enum: ["corporate"]},
legal_name: %Schema{type: :string},
commercial_name: %Schema{type: :string},
ruc: %Schema{type: :string},
legal_rep_name: %Schema{type: :string},
legal_rep_document_id: %Schema{type: :string},
email: %Schema{type: :string, format: :email},
phone: %Schema{type: :string},
address: %Schema{type: :string}
}
})
end
defmodule CustomerData do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "Customer",
oneOf: [IndividualCustomerData, CorporateCustomerData],
discriminator: %OpenApiSpex.Discriminator{
propertyName: "customer_type",
mapping: %{
"individual" => IndividualCustomerData,
"corporate" => CorporateCustomerData
}
}
})
end
defmodule CreateCustomer do
require OpenApiSpex
alias OpenApiSpex.Schema
OpenApiSpex.schema(%{
title: "CreateCustomer",
type: :object,
required: [:first_name, :last_name],
properties: %{
first_name: %Schema{type: :string},
last_name: %Schema{type: :string},
email: %Schema{type: :string, format: :email},
phone: %Schema{type: :string},
birth_date: %Schema{type: :string, format: :date},
gender: %Schema{type: :string},
document_id: %Schema{type: :string}
}
})
end
defmodule CreateCorporateCustomer do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "CreateCorporateCustomer",
type: :object,
required: [:legal_name, :ruc],
properties: %{
legal_name: %Schema{type: :string},
commercial_name: %Schema{type: :string},
ruc: %Schema{type: :string},
legal_rep_name: %Schema{type: :string},
legal_rep_document_id: %Schema{type: :string},
email: %Schema{type: :string, format: :email},
phone: %Schema{type: :string}
phone: %Schema{type: :string},
address: %Schema{type: :string}
}
})
end
defmodule CustomerListResponse do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "CustomerListResponse",
type: :object,
properties: %{
data: %Schema{type: :array, items: CustomerData},
meta: PaginationMeta
}
})
end
defmodule CustomerResponse do
require OpenApiSpex
OpenApiSpex.schema(%{
title: "CustomerResponse",
type: :object,
properties: %{
data: CustomerData
}
})
end