Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
use App\Models\Foundation\Summit\Events\Presentations\TrackQuestions\TrackQuestionTemplateConstants;
use App\Models\Foundation\Summit\Repositories\ITrackQuestionTemplateRepository;
use App\Services\Model\ITrackQuestionTemplateService;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request;
use libs\utils\PaginationValidationRules;
use OpenApi\Attributes as OA;
use models\exceptions\EntityNotFoundException;
use models\exceptions\ValidationException;
use Exception;
Expand Down Expand Up @@ -65,6 +67,30 @@ public function __construct
/**
* @return mixed
*/
#[OA\Get(
path: '/api/v1/track-question-templates',
summary: 'Get all track question templates',
description: 'Returns a paginated list of track question templates',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
parameters: [
new OA\Parameter(name: 'page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 1)),
new OA\Parameter(name: 'per_page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 5)),
new OA\Parameter(name: 'filter', in: 'query', required: false, description: 'Filter by name, label or class_name', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by id, name, or label', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations (tracks)', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Success',
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedTrackQuestionTemplatesResponse')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function getTrackQuestionTemplates(){
$values = Request::all();
$rules = PaginationValidationRules::get();
Expand Down Expand Up @@ -160,6 +186,32 @@ public function getTrackQuestionTemplates(){
/**
* @return mixed
*/
#[OA\Post(
path: '/api/v1/track-question-templates',
summary: 'Create a new track question template',
description: 'Creates a new track question template',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplateRequest')
),
parameters: [
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_CREATED,
description: 'Track Question Template Created',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
),
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function addTrackQuestionTemplate(){
try {

Expand Down Expand Up @@ -205,6 +257,28 @@ public function addTrackQuestionTemplate(){
* @param $track_question_template_id
* @return mixed
*/
#[OA\Get(
path: '/api/v1/track-question-templates/{track_question_template_id}',
summary: 'Get a track question template by id',
description: 'Returns a single track question template',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Success',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function getTrackQuestionTemplate($track_question_template_id){
try {

Expand Down Expand Up @@ -234,6 +308,33 @@ public function getTrackQuestionTemplate($track_question_template_id){
* @param $track_question_template_id
* @return mixed
*/
#[OA\Put(
path: '/api/v1/track-question-templates/{track_question_template_id}',
summary: 'Update a track question template',
description: 'Updates an existing track question template',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplateRequest')
),
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Track Question Template Updated',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
),
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function updateTrackQuestionTemplate($track_question_template_id){
try {

Expand Down Expand Up @@ -278,6 +379,23 @@ public function updateTrackQuestionTemplate($track_question_template_id){
* @param $track_question_template_id
* @return mixed
*/
#[OA\Delete(
path: '/api/v1/track-question-templates/{track_question_template_id}',
summary: 'Delete a track question template',
description: 'Deletes a track question template',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
],
responses: [
new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Question Template Deleted'),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function deleteTrackQuestionTemplate($track_question_template_id){
try {

Expand All @@ -302,6 +420,27 @@ public function deleteTrackQuestionTemplate($track_question_template_id){
/**
* @return mixed
*/
#[OA\Get(
path: '/api/v1/track-question-templates/metadata',
summary: 'Get track question templates metadata',
description: 'Returns metadata about available track question template types',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Success',
content: new OA\JsonContent(
type: 'object',
properties: [
new OA\Property(property: 'class_names', type: 'array', items: new OA\Items(type: 'string')),
]
)
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function getTrackQuestionTemplateMetadata(){
return $this->ok
(
Expand All @@ -318,6 +457,28 @@ public function getTrackQuestionTemplateMetadata(){
* @param $track_question_template_value_id
* @return mixed
*/
#[OA\Get(
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
summary: 'Get a track question template value',
description: 'Returns a single track question template value',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Success',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function getTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
try {

Expand Down Expand Up @@ -350,6 +511,33 @@ public function getTrackQuestionTemplateValue($track_question_template_id, $trac
* @param $track_question_template_id
* @return mixed
*/
#[OA\Post(
path: '/api/v1/track-question-templates/{track_question_template_id}/values',
summary: 'Add a value to a track question template',
description: 'Adds a new value to a multi-value track question template',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplateRequest')
),
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_CREATED,
description: 'Track Question Template Value Created',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
),
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function addTrackQuestionTemplateValue($track_question_template_id){
try {

Expand Down Expand Up @@ -399,6 +587,34 @@ public function addTrackQuestionTemplateValue($track_question_template_id){
* @param $track_question_template_value_id
* @return mixed
*/
#[OA\Put(
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
summary: 'Update a track question template value',
description: 'Updates an existing track question template value',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplateRequest')
),
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: 'Track Question Template Value Updated',
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
),
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function updateTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
try {

Expand Down Expand Up @@ -449,6 +665,24 @@ public function updateTrackQuestionTemplateValue($track_question_template_id, $t
* @param $track_question_template_value_id
* @return mixed
*/
#[OA\Delete(
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
summary: 'Delete a track question template value',
description: 'Deletes a track question template value',
tags: ['track-question-templates'],
security: [['Bearer' => []]],
parameters: [
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
],
responses: [
new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Question Template Value Deleted'),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function deleteTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
try {
$this->track_question_template_service->deleteTrackQuestionValueTemplate
Expand All @@ -472,4 +706,4 @@ public function deleteTrackQuestionTemplateValue($track_question_template_id, $t
return $this->error500($ex);
}
}
}
}
Loading