diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitPresentationActionTypeApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitPresentationActionTypeApiController.php index 9daabb3ee..da38f639f 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitPresentationActionTypeApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitPresentationActionTypeApiController.php @@ -1,4 +1,5 @@ -repository = $repository; $this->summit_repository = $summit_repository; @@ -84,7 +87,7 @@ protected function addChild(Summit $summit, array $payload): IEntity /** * @inheritDoc */ - function getAddValidationRules(array $payload): array + public function getAddValidationRules(array $payload): array { return SummitPresentationActionTypeValidationRulesFactory::build($payload, false); } @@ -116,7 +119,7 @@ protected function getChildFromSummit(Summit $summit, $child_id): ?IEntity /** * @inheritDoc */ - function getUpdateValidationRules(array $payload): array + public function getUpdateValidationRules(array $payload): array { return SummitPresentationActionTypeValidationRulesFactory::build($payload, true); } @@ -133,10 +136,259 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I * @param $summit_id * @return \Illuminate\Http\JsonResponse|mixed */ + #[OA\Post( + path: '/api/v1/summits/{id}/presentation-action-types', + summary: 'Create a new presentation action type', + operationId: 'createPresentationActionType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionTypeCreateRequest') + ), + responses: [ + new OA\Response( + response: Response::HTTP_CREATED, + description: 'Presentation action type created', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType') + ), + 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 add($summit_id) + { + return parent::add($summit_id); + } + + /** + * @param $summit_id + * @param $action_id + * @return \Illuminate\Http\JsonResponse|mixed + */ + #[OA\Get( + path: '/api/v1/summits/{id}/presentation-action-types/{action_id}', + summary: 'Get a presentation action type by ID', + operationId: 'getPresentationActionType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::ReadAllSummitData, + SummitScopes::ReadSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Successful response', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType') + ), + 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_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + public function get($summit_id, $action_id) + { + return parent::get($summit_id, $action_id); + } + + /** + * @param $summit_id + * @param $action_id + * @return \Illuminate\Http\JsonResponse|mixed + */ + #[OA\Put( + path: '/api/v1/summits/{id}/presentation-action-types/{action_id}', + summary: 'Update a presentation action type', + operationId: 'updatePresentationActionType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionTypeUpdateRequest') + ), + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Presentation action type updated', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType') + ), + 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 update($summit_id, $action_id) + { + return parent::update($summit_id, $action_id); + } + + /** + * @param $summit_id + * @param $action_id + * @return \Illuminate\Http\JsonResponse|mixed + */ + #[OA\Delete( + path: '/api/v1/summits/{id}/presentation-action-types/{action_id}', + summary: 'Delete a presentation action type', + operationId: 'deletePresentationActionType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')), + ], + responses: [ + new OA\Response(response: Response::HTTP_NO_CONTENT, description: "No Content"), + 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_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + public function delete($summit_id, $action_id) + { + return parent::delete($summit_id, $action_id); + } + + /** + * @param $summit_id + * @return \Illuminate\Http\JsonResponse|mixed + */ + #[OA\Get( + path: '/api/v1/summits/{id}/presentation-action-types', + summary: 'Get all presentation action types for a summit', + operationId: 'getAllPresentationActionTypes', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + IGroup::TrackChairs, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::ReadAllSummitData, + SummitScopes::ReadSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter( + name: 'page', + in: 'query', + required: false, + description: 'Page number for pagination', + schema: new OA\Schema(type: 'integer', example: 1) + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + required: false, + description: 'Items per page', + schema: new OA\Schema(type: 'integer', example: 10, maximum: 100) + ), + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by label (label=@value, label==value)', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-label, +/-order', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'selection_plan_id', in: 'query', description: 'Filter by selection plan and include order field', schema: new OA\Schema(type: 'integer')), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Successful response', + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPresentationActionTypesResponse') + ), + 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_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] public function getAllBySummit($summit_id) { $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id); - if (is_null($summit)) return $this->error404(); + if (is_null($summit)) + return $this->error404(); return $this->_getAll( function () { @@ -178,10 +430,70 @@ function () { * @param $summit_id * @return \Illuminate\Http\JsonResponse|mixed */ + #[OA\Get( + path: '/api/v1/summits/{id}/presentation-action-types/csv', + summary: 'Get all presentation action types for a summit in CSV format', + operationId: 'getAllPresentationActionTypesCSV', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::TrackChairsAdmins, + ] + ], + security: [ + [ + 'presentation_action_types_oauth2' => [ + SummitScopes::ReadAllSummitData, + SummitScopes::ReadSummitData, + ] + ] + ], + tags: ['Summits', 'Presentation Action Types'], + parameters: [ + new OA\Parameter( + name: 'page', + in: 'query', + required: false, + description: 'Page number for pagination', + schema: new OA\Schema(type: 'integer', example: 1) + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + required: false, + description: 'Items per page', + schema: new OA\Schema(type: 'integer', example: 10, maximum: 100) + ), + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by label (label=@value, label==value)', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-label, +/-order', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'selection_plan_id', in: 'query', description: 'Filter by selection plan and include order field', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'columns', in: 'query', description: 'Comma-separated list of columns (allowed: id, created, last_edited, label, order)', schema: new OA\Schema(type: 'string')), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'CSV file', + content: new OA\MediaType( + mediaType: 'text/csv', + schema: new OA\Schema(type: 'string', format: 'binary') + ) + ), + 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 getAllBySummitCSV($summit_id) { $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id); - if (is_null($summit)) return $this->error404(); + if (is_null($summit)) + return $this->error404(); return $this->_getAllCSV( function () { diff --git a/app/Swagger/Security/PresentationActionTypesAuthSchema.php b/app/Swagger/Security/PresentationActionTypesAuthSchema.php new file mode 100644 index 000000000..464eed28a --- /dev/null +++ b/app/Swagger/Security/PresentationActionTypesAuthSchema.php @@ -0,0 +1,28 @@ + 'Read All Summit Data', + SummitScopes::ReadSummitData => 'Read Summit Data', + SummitScopes::WriteSummitData => 'Write Summit Data', + ], + ), + ], +) +] +class PresentationActionTypesAuthSchema +{ +} diff --git a/app/Swagger/SummitPresentationSchemas.php b/app/Swagger/SummitPresentationSchemas.php index 54f150301..bf2e70ed8 100644 --- a/app/Swagger/SummitPresentationSchemas.php +++ b/app/Swagger/SummitPresentationSchemas.php @@ -145,3 +145,64 @@ class PresentationTrackChairScoreTypeCreateRequest {} class PresentationTrackChairScoreTypeUpdateRequest {} // End Track Chair Score Types + + +#[OA\Schema( + schema: 'PresentationActionType', + type: 'object', + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 1), + new OA\Property(property: 'created', type: 'integer', example: 1630500518), + new OA\Property(property: 'last_edited', type: 'integer', example: 1630500518), + new OA\Property(property: 'label', type: 'string', example: 'Review'), + new OA\Property(property: 'summit_id', type: 'integer', example: 42, description: 'Summit ID, add ?expand=summit to get full summit object'), + new OA\Property(property: 'order', type: 'integer', example: 1, description: 'Order within a selection plan. Only present when filtering by selection_plan_id', ), + ] +)] +class PresentationActionTypeSchema +{ +} + +#[OA\Schema( + schema: 'PaginatedPresentationActionTypesResponse', + 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/PresentationActionType') + ) + ] + ) + ] +)] +class PaginatedPresentationActionTypesResponseSchema +{ +} + +#[OA\Schema( + schema: 'PresentationActionTypeCreateRequest', + type: 'object', + required: ['label'], + properties: [ + new OA\Property(property: 'label', type: 'string', example: 'Review', maxLength: 255), + new OA\Property(property: 'selection_plan_id', type: 'integer', example: 42, description: 'If provided, the order field will be set within the context of the selection plan'), + ] +)] +class PresentationActionTypeCreateRequestSchema +{ +} + +#[OA\Schema( + schema: 'PresentationActionTypeUpdateRequest', + type: 'object', + properties: [ + new OA\Property(property: 'label', type: 'string', example: 'Review', maxLength: 255), + ] +)] +class PresentationActionTypeUpdateRequestSchema +{ +} \ No newline at end of file