All checks were successful
Build and Publish / build-release (push) Successful in 1m23s
164 lines
3.9 KiB
Elixir
164 lines
3.9 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,
|
|
properties: %{
|
|
plan_id: %Schema{type: :string},
|
|
name: %Schema{type: :string},
|
|
premium: %Schema{type: :number},
|
|
coverage_details: %Schema{type: :object, additionalProperties: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule QuoteSubmission do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "QuoteSubmission",
|
|
type: :object,
|
|
required: [:recorded_by, :quote_id],
|
|
properties: %{
|
|
recorded_by: %Schema{type: :string},
|
|
quote_id: %Schema{type: :string},
|
|
valid_until: %Schema{type: :string, format: :date},
|
|
plans: %Schema{type: :array, items: Plan},
|
|
document_url: %Schema{type: :string},
|
|
document_data: %Schema{type: :object, additionalProperties: true}
|
|
}
|
|
})
|
|
end
|
|
|
|
defmodule SolicitationSubmission do
|
|
require OpenApiSpex
|
|
|
|
OpenApiSpex.schema(%{
|
|
title: "SolicitationSubmission",
|
|
type: :object,
|
|
required: [:recorded_by],
|
|
properties: %{
|
|
recorded_by: %Schema{type: :string}
|
|
}
|
|
})
|
|
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},
|
|
task_info: %Schema{type: :object},
|
|
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},
|
|
task_info: %Schema{type: :object},
|
|
submission: %Schema{type: :object, nullable: true},
|
|
attachments: %Schema{type: :array, items: %Schema{type: :string}},
|
|
status: %Schema{type: :string, enum: ["created", "draft", "approved", "completed"]},
|
|
version: %Schema{type: :integer},
|
|
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
|