diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php index 30cfdfd11..770ad7378 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PresentationCategoryGroupController.php @@ -15,9 +15,11 @@ use App\Models\Foundation\Summit\Events\Presentations\PresentationCategoryGroupConstants; use App\Models\Foundation\Summit\Repositories\IPresentationCategoryGroupRepository; use App\Services\Model\IPresentationCategoryGroupService; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Validator; +use OpenApi\Attributes as OA; use libs\utils\PaginationValidationRules; use models\exceptions\ValidationException; use models\oauth2\IResourceServerContext; @@ -71,6 +73,32 @@ public function __construct * @param $summit_id * @return mixed */ + #[OA\Get( + path: '/api/v1/summits/{id}/track-groups', + summary: 'Get all track groups by summit', + description: 'Returns a paginated list of track groups (presentation category groups) for a summit', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + 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, description, slug, track_title, track_code, group_title, group_code, voting_visible, chair_visible, or class_name', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by id, name, or slug', 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/PaginatedPresentationCategoryGroupsResponse') + ), + 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 getAllBySummit($summit_id){ $values = Request::all(); $rules = PaginationValidationRules::get(); @@ -290,6 +318,29 @@ public function getAllBySummitCSV($summit_id){ * @param $track_group_id * @return mixed */ + #[OA\Get( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}', + summary: 'Get a track group by id', + description: 'Returns a single track group by id', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + 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/PresentationCategoryGroup') + ), + 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 getTrackGroupBySummit($summit_id, $track_group_id){ try { $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id); @@ -318,6 +369,33 @@ public function getTrackGroupBySummit($summit_id, $track_group_id){ * @param $track_group_id * @return mixed */ + #[OA\Put( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}', + summary: 'Update a track group', + description: 'Updates an existing track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationCategoryGroupRequest') + ), + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Track Group Updated', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationCategoryGroup') + ), + 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 updateTrackGroupBySummit($summit_id, $track_group_id){ try { @@ -364,6 +442,24 @@ public function updateTrackGroupBySummit($summit_id, $track_group_id){ * @param $track_group_id * @return mixed */ + #[OA\Delete( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}', + summary: 'Delete a track group', + description: 'Deletes a track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + ], + responses: [ + new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Group 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 deleteTrackGroupBySummit($summit_id, $track_group_id){ try { @@ -393,6 +489,32 @@ public function deleteTrackGroupBySummit($summit_id, $track_group_id){ * @param $summit_id * @return mixed */ + #[OA\Post( + path: '/api/v1/summits/{id}/track-groups', + summary: 'Create a new track group', + description: 'Creates a new track group for a summit', + tags: ['track-groups'], + security: [['Bearer' => []]], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PresentationCategoryGroupRequest') + ), + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + ], + responses: [ + new OA\Response( + response: Response::HTTP_CREATED, + description: 'Track Group Created', + content: new OA\JsonContent(ref: '#/components/schemas/PresentationCategoryGroup') + ), + 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 addTrackGroupBySummit($summit_id){ try { @@ -440,6 +562,25 @@ public function addTrackGroupBySummit($summit_id){ * @param $track_id * @return mixed */ + #[OA\Put( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id}', + summary: 'Associate a track to a track group', + description: 'Associates a presentation category (track) to a track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + new OA\Parameter(name: 'track_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track id'), + ], + responses: [ + new OA\Response(response: Response::HTTP_OK, description: 'Track Associated'), + 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 associateTrack2TrackGroup($summit_id, $track_group_id, $track_id){ try { @@ -471,6 +612,25 @@ public function associateTrack2TrackGroup($summit_id, $track_group_id, $track_id * @param $track_id * @return mixed */ + #[OA\Delete( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}/tracks/{track_id}', + summary: 'Disassociate a track from a track group', + description: 'Removes the association between a presentation category (track) and a track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + new OA\Parameter(name: 'track_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track id'), + ], + responses: [ + new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Disassociated'), + 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 disassociateTrack2TrackGroup($summit_id, $track_group_id, $track_id){ try { @@ -502,6 +662,25 @@ public function disassociateTrack2TrackGroup($summit_id, $track_group_id, $track * @param $group_id * @return mixed */ + #[OA\Put( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id}', + summary: 'Associate an allowed group to a track group', + description: 'Associates a group to the list of allowed groups for a private track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + new OA\Parameter(name: 'group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The group id'), + ], + responses: [ + new OA\Response(response: Response::HTTP_OK, description: 'Group Associated'), + 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 associateAllowedGroup2TrackGroup($summit_id, $track_group_id, $group_id){ try { @@ -533,6 +712,25 @@ public function associateAllowedGroup2TrackGroup($summit_id, $track_group_id, $g * @param $group_id * @return mixed */ + #[OA\Delete( + path: '/api/v1/summits/{id}/track-groups/{track_group_id}/allowed-groups/{group_id}', + summary: 'Disassociate an allowed group from a track group', + description: 'Removes a group from the list of allowed groups for a private track group', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + new OA\Parameter(name: 'track_group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track group id'), + new OA\Parameter(name: 'group_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The group id'), + ], + responses: [ + new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Group Disassociated'), + 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 disassociateAllowedGroup2TrackGroup($summit_id, $track_group_id, $group_id){ try { @@ -562,6 +760,31 @@ public function disassociateAllowedGroup2TrackGroup($summit_id, $track_group_id, * @param $summit_id * @return mixed */ + #[OA\Get( + path: '/api/v1/summits/{id}/track-groups/metadata', + summary: 'Get track groups metadata', + description: 'Returns metadata about available track group types', + tags: ['track-groups'], + security: [['Bearer' => []]], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The summit id'), + ], + 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_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] public function getMetadata($summit_id){ $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id); if (is_null($summit)) return $this->error404(); @@ -571,4 +794,4 @@ public function getMetadata($summit_id){ $this->repository->getMetadata($summit) ); } -} \ No newline at end of file +} diff --git a/app/Swagger/SummitPresentationSchemas.php b/app/Swagger/SummitPresentationSchemas.php index 6b3e2f895..bdfc690e7 100644 --- a/app/Swagger/SummitPresentationSchemas.php +++ b/app/Swagger/SummitPresentationSchemas.php @@ -4,4 +4,71 @@ use OpenApi\Attributes as OA; +#[OA\Schema( + schema: 'PresentationCategoryGroup', + type: 'object', + required: ['id', 'created', 'last_edited', 'name', 'class_name', 'summit_id', 'max_attendee_votes'], + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 1), + new OA\Property(property: 'created', type: 'integer', example: 1634567890), + new OA\Property(property: 'last_edited', type: 'integer', example: 1634567890), + new OA\Property(property: 'name', type: 'string', example: 'Track Group Name'), + new OA\Property(property: 'color', type: 'string', example: '#FF5733'), + new OA\Property(property: 'description', type: 'string', example: 'Group description'), + new OA\Property(property: 'class_name', type: 'string', example: 'PresentationCategoryGroup'), + new OA\Property(property: 'summit_id', type: 'integer', example: 1), + new OA\Property(property: 'begin_attendee_voting_period_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'end_attendee_voting_period_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'max_attendee_votes', type: 'integer', example: 3), + new OA\Property( + property: 'tracks', + type: 'array', + items: new OA\Items( + anyOf: [ + new OA\Schema(type: 'integer'), + new OA\Schema(type: 'PresentationCategory') + ] + ) + ), + ] +)] +class PresentationCategoryGroup {} + +#[OA\Schema( + schema: 'PaginatedPresentationCategoryGroupsResponse', + 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/PresentationCategoryGroup') + ) + ] + ) + ] +)] +class PaginatedPresentationCategoryGroupsResponse {} + +#[OA\Schema( + schema: 'PresentationCategoryGroupRequest', + type: 'object', + required: ['name', 'class_name'], + properties: [ + new OA\Property(property: 'name', type: 'string', example: 'Track Group Name'), + new OA\Property(property: 'class_name', type: 'string', example: 'PresentationCategoryGroup'), + new OA\Property(property: 'description', type: 'string', example: 'Group description'), + new OA\Property(property: 'color', type: 'string', example: '#FF5733'), + new OA\Property(property: 'max_attendee_votes', type: 'integer', example: 3), + new OA\Property(property: 'begin_attendee_voting_period_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'end_attendee_voting_period_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'submission_begin_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'submission_end_date', type: 'integer', example: 1634567890), + new OA\Property(property: 'max_submission_allowed_per_user', type: 'integer', example: 5), + ] +)] +class PresentationCategoryGroupRequest {} + //