diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTrackChairRatingTypesApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTrackChairRatingTypesApiController.php index 13bf8057f..8c0abdcb9 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTrackChairRatingTypesApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTrackChairRatingTypesApiController.php @@ -16,11 +16,12 @@ use App\Models\Foundation\Summit\Repositories\ISelectionPlanRepository; use App\ModelSerializers\SerializerUtils; use App\Services\Model\ITrackChairRankingService; +use Illuminate\Http\Response; use models\oauth2\IResourceServerContext; use models\summit\ISummitRepository; use models\utils\IBaseRepository; -use models\utils\IEntity; use ModelSerializers\SerializerRegistry; +use OpenApi\Attributes as OA; use utils\Filter; use utils\FilterElement; @@ -89,11 +90,84 @@ protected function getRepository(): IBaseRepository return $this->repository; } - /** - * @param $summit_id - * @param $selection_plan_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Get( + path: "/api/v1/summits/{id}/selection-plans/{selection_plan_id}/track-chair-rating-types", + description: "Get all track chair rating types for a selection plan", + summary: "Get all track chair rating types", + operationId: "getAllTrackChairRatingTypes", + tags: ['Track Chair Rating Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'selection_plan_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The selection plan id' + ), + new OA\Parameter( + name: 'page', + in: 'query', + required: false, + schema: new OA\Schema(type: 'integer', default: 1), + description: 'Page number' + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + required: false, + schema: new OA\Schema(type: 'integer', default: 10), + description: 'Items per page' + ), + new OA\Parameter( + name: 'filter', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Filter expression (e.g., name=@Technical)' + ), + new OA\Parameter( + name: 'order', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Order by field (e.g., +order, -name)' + ), + new OA\Parameter( + name: 'expand', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Expand relationships (score_types,selection_plan)' + ), + new OA\Parameter( + name: 'relations', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to include (score_types)' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: 'Success', + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPresentationTrackChairRatingTypesResponse') + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + 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 getTrackChairRatingTypes($summit_id, $selection_plan_id) { $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find(intval($summit_id)); @@ -134,12 +208,62 @@ function () { ); } - /** - * @param $summit_id - * @param $selection_plan_id - * @param $type_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Get( + path: "/api/v1/summits/{id}/selection-plans/{selection_plan_id}/track-chair-rating-types/{type_id}", + description: "Get a specific track chair rating type by id", + summary: "Get track chair rating type", + operationId: "getTrackChairRatingType", + tags: ['Track Chair Rating Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'selection_plan_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The selection plan id' + ), + new OA\Parameter( + name: 'type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The rating type id' + ), + new OA\Parameter( + name: 'expand', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Expand relationships (score_types,selection_plan)' + ), + new OA\Parameter( + name: 'relations', + in: 'query', + required: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to include (score_types)' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: 'Success', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationTrackChairRatingType') + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function getTrackChairRatingType($summit_id, $selection_plan_id, $type_id) { return $this->processRequest(function () use ($summit_id, $selection_plan_id, $type_id) { @@ -162,11 +286,47 @@ public function getTrackChairRatingType($summit_id, $selection_plan_id, $type_id }); } - /** - * @param $summit_id - * @param $selection_plan_id - * @return IEntity - */ + #[OA\Post( + path: "/api/v1/summits/{id}/selection-plans/{selection_plan_id}/track-chair-rating-types", + description: "Create a new track chair rating type", + summary: "Create track chair rating type", + operationId: "createTrackChairRatingType", + tags: ['Track Chair Rating Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'selection_plan_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The selection plan id' + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationTrackChairRatingTypeCreateRequest') + ), + responses: [ + new OA\Response( + response: 201, + description: 'Created', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationTrackChairRatingType') + ), + 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_FORBIDDEN, description: "Forbidden"), + 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 addTrackChairRatingType($summit_id, $selection_plan_id) { return $this->processRequest(function () use ($summit_id, $selection_plan_id) { @@ -190,12 +350,54 @@ public function addTrackChairRatingType($summit_id, $selection_plan_id) { }); } - /** - * @param $summit_id - * @param $selection_plan_id - * @param $type_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Put( + path: "/api/v1/summits/{id}/selection-plans/{selection_plan_id}/track-chair-rating-types/{type_id}", + description: "Update an existing track chair rating type", + summary: "Update track chair rating type", + operationId: "updateTrackChairRatingType", + tags: ['Track Chair Rating Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'selection_plan_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The selection plan id' + ), + new OA\Parameter( + name: 'type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The rating type id' + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationTrackChairRatingTypeUpdateRequest') + ), + responses: [ + new OA\Response( + response: 200, + description: 'Success', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationTrackChairRatingType') + ), + 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_FORBIDDEN, description: "Forbidden"), + 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 updateTrackChairRatingType($summit_id, $selection_plan_id, $type_id) { return $this->processRequest(function () use ($summit_id, $selection_plan_id, $type_id) { @@ -219,12 +421,44 @@ public function updateTrackChairRatingType($summit_id, $selection_plan_id, $type }); } - /** - * @param $summit_id - * @param $selection_plan_id - * @param $type_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Delete( + path: "/api/v1/summits/{id}/selection-plans/{selection_plan_id}/track-chair-rating-types/{type_id}", + description: "Delete a track chair rating type", + summary: "Delete track chair rating type", + operationId: "deleteTrackChairRatingType", + tags: ['Track Chair Rating Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'selection_plan_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The selection plan id' + ), + new OA\Parameter( + name: 'type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The rating type id' + ) + ], + responses: [ + new OA\Response(response: 204, description: 'No Content'), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function deleteTrackChairRatingType($summit_id, $selection_plan_id, $type_id) { return $this->processRequest(function () use ($summit_id, $selection_plan_id, $type_id) { @@ -239,4 +473,4 @@ public function deleteTrackChairRatingType($summit_id, $selection_plan_id, $type return $this->deleted(); }); } -} \ No newline at end of file +} diff --git a/app/Swagger/SummitPresentationSchemas.php b/app/Swagger/SummitPresentationSchemas.php index 6b3e2f895..8f8a3cf2c 100644 --- a/app/Swagger/SummitPresentationSchemas.php +++ b/app/Swagger/SummitPresentationSchemas.php @@ -4,4 +4,80 @@ use OpenApi\Attributes as OA; +#[OA\Schema( + schema: 'PresentationTrackChairRatingType', + type: 'object', + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 1), + new OA\Property(property: 'created', type: 'integer', description: 'Unix timestamp', example: 1640995200), + new OA\Property(property: 'last_edited', type: 'integer', description: 'Unix timestamp', example: 1640995200), + new OA\Property(property: 'name', type: 'string', example: 'Technical Merit'), + new OA\Property(property: 'weight', type: 'number', format: 'float', example: 1.5), + new OA\Property(property: 'order', type: 'integer', example: 1), + new OA\Property(property: 'selection_plan_id', type: 'integer', example: 1), + new OA\Property( + property: 'score_types', + type: 'array', + items: new OA\Items(type: 'integer'), + example: [1, 2, 3] + ) + ] +)] +class PresentationTrackChairRatingTypeSchema {} + +#[OA\Schema( + schema: 'PaginatedPresentationTrackChairRatingTypesResponse', + allOf: [ + new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'), + new OA\Schema( + type: 'object', + properties: [ + new OA\Property( + property: 'data', + type: 'array', + items: new OA\Items(ref: '#/components/schemas/PresentationTrackChairRatingType') + ) + ] + ) + ] +)] +class PaginatedPresentationTrackChairRatingTypesResponseSchema {} + +#[OA\Schema( + schema: 'PresentationTrackChairRatingTypeCreateRequest', + type: 'object', + required: ['name', 'weight'], + properties: [ + new OA\Property(property: 'name', type: 'string', example: 'Technical Merit'), + new OA\Property(property: 'weight', type: 'number', format: 'float', example: 1.5), + new OA\Property(property: 'order', type: 'integer', example: 1, nullable: true), + new OA\Property( + property: 'score_types', + type: 'array', + items: new OA\Items(type: 'integer'), + example: [1, 2, 3], + nullable: true + ) + ] +)] +class PresentationTrackChairRatingTypeCreateRequestSchema {} + +#[OA\Schema( + schema: 'PresentationTrackChairRatingTypeUpdateRequest', + type: 'object', + properties: [ + new OA\Property(property: 'name', type: 'string', example: 'Technical Merit', nullable: true), + new OA\Property(property: 'weight', type: 'number', format: 'float', example: 1.5, nullable: true), + new OA\Property(property: 'order', type: 'integer', example: 1, nullable: true), + new OA\Property( + property: 'score_types', + type: 'array', + items: new OA\Items(type: 'integer'), + example: [1, 2, 3], + nullable: true + ) + ] +)] +class PresentationTrackChairRatingTypeUpdateRequestSchema {} + //