diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeeBadgePrintApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeeBadgePrintApiController.php index d5b4dcd65..a9c4f8e70 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeeBadgePrintApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitAttendeeBadgePrintApiController.php @@ -1,4 +1,7 @@ -repository = $repository; $this->summit_repository = $summit_repository; @@ -49,28 +55,114 @@ public function __construct use ParametrizedGetAll; + #[OA\Get( + path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints", + operationId: "getAllBadgePrintsByTicket", + summary: "Get all badge prints for a ticket", + description: "Returns a paginated list of badge print records for a specific ticket. Allows ordering, filtering and pagination.", + security: [ + [ + "summit_attendee_badge_print_oauth2" => [ + SummitScopes::ReadAllSummitData + ] + ] + ], + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + tags: ["Summit Badge Prints"], + 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'), + description: 'The page number' + ), + new OA\Parameter( + name: 'page_size', + in: 'query', + required: false, + schema: new OA\Schema(type: 'integer'), + description: 'The number of pages in each page', + ), + new OA\Parameter( + name: "ticket_id", + in: "path", + required: true, + description: "Ticket ID", + schema: new OA\Schema(type: "integer") + ), + new OA\Parameter( + name: "filter[]", + in: "query", + required: false, + description: "Filter badge prints. Available filters: id==, view_type_id==, created (>, <, <=, >=, ==, []), print_date (>, <, <=, >=, ==, []), requestor_full_name (==, @@, =@), requestor_email (==, @@, =@)", + schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")), + explode: true + ), + new OA\Parameter( + name: "order", + in: "query", + required: false, + description: "Order by field. Valid fields: id, created, view_type_id, print_date, requestor_full_name, requestor_email", + schema: new OA\Schema(type: "string") + ), + new OA\Parameter( + name: "expand", + in: "query", + required: false, + description: "Expand related entities. Available expansions: requestor, badge, view_type", + schema: new OA\Schema(type: "string") + ), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: "Success", + content: new OA\JsonContent(ref: "#/components/schemas/PaginatedSummitAttendeeBadgePrintsResponse") + ), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit or ticket not found"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Invalid filter or order parameter"), + ] + )] public function getAllBySummitAndTicket($summit_id, $ticket_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 () { return [ - 'id' => ['=='], - 'view_type_id' => ['=='], - 'created' => ['>', '<', '<=', '>=', '==','[]'], - 'print_date' => ['>', '<', '<=', '>=', '==','[]'], - 'requestor_full_name' => ['==','@@','=@'], - 'requestor_email' => ['==','@@','=@'], + 'id' => ['=='], + 'view_type_id' => ['=='], + 'created' => ['>', '<', '<=', '>=', '==', '[]'], + 'print_date' => ['>', '<', '<=', '>=', '==', '[]'], + 'requestor_full_name' => ['==', '@@', '=@'], + 'requestor_email' => ['==', '@@', '=@'], ]; }, function () { return [ 'id' => 'sometimes|integer', 'view_type_id' => 'sometimes|integer', - 'created' => 'sometimes|date_format:U|epoch_seconds', - 'print_date'=> 'sometimes|date_format:U|epoch_seconds', + 'created' => 'sometimes|date_format:U|epoch_seconds', + 'print_date' => 'sometimes|date_format:U|epoch_seconds', 'requestor_full_name' => 'sometimes|string', 'requestor_email' => 'sometimes|string', ]; @@ -95,28 +187,96 @@ function ($filter) use ($summit, $ticket_id) { ); } + #[OA\Get( + path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints/csv", + operationId: "getAllBadgePrintsByTicketCSV", + summary: "Export badge prints to CSV", + description: "Exports all badge print records for a specific ticket to CSV format. Allows ordering and filtering.", + security: [ + [ + "summit_attendee_badge_print_oauth2" => [ + SummitScopes::ReadAllSummitData + ] + ] + ], + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + tags: ["Summit Badge Prints"], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: "ticket_id", + in: "path", + required: true, + description: "Ticket ID", + schema: new OA\Schema(type: "integer") + ), + new OA\Parameter( + name: "filter[]", + in: "query", + required: false, + description: "Filter badge prints. Available filters: id==, view_type_id==, created (>, <, <=, >=, ==, []), print_date (>, <, <=, >=, ==, []), requestor_full_name (==, @@, =@), requestor_email (==, @@, =@)", + schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")), + explode: true + ), + new OA\Parameter( + name: "order", + in: "query", + required: false, + description: "Order by field. Valid fields: id, created, view_type_id, print_date, requestor_full_name, requestor_email", + 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_NOT_FOUND, description: "Summit or ticket not found"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Invalid filter or order parameter"), + ] + )] public function getAllBySummitAndTicketCSV($summit_id, $ticket_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 () { return [ - 'id' => ['=='], - 'view_type_id' => ['=='], - 'created' => ['>', '<', '<=', '>=', '==','[]'], - 'print_date' => ['>', '<', '<=', '>=', '==','[]'], - 'requestor_full_name' => ['==','@@','=@'], - 'requestor_email' => ['==','@@','=@'], + 'id' => ['=='], + 'view_type_id' => ['=='], + 'created' => ['>', '<', '<=', '>=', '==', '[]'], + 'print_date' => ['>', '<', '<=', '>=', '==', '[]'], + 'requestor_full_name' => ['==', '@@', '=@'], + 'requestor_email' => ['==', '@@', '=@'], ]; }, function () { return [ 'id' => 'sometimes|integer', 'view_type_id' => 'sometimes|integer', - 'created' => 'sometimes|date_format:U|epoch_seconds', - 'print_date'=> 'sometimes|date_format:U|epoch_seconds', + 'created' => 'sometimes|date_format:U|epoch_seconds', + 'print_date' => 'sometimes|date_format:U|epoch_seconds', 'requestor_full_name' => 'sometimes|string', 'requestor_email' => 'sometimes|string', ]; @@ -155,20 +315,61 @@ function () { ); } - /** - * @param $summit_id - * @param $ticket_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Delete( + path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints", + operationId: "deleteBadgePrintsByTicket", + summary: "Delete all badge prints for a ticket", + description: "Deletes all badge print records for a specific ticket", + security: [ + [ + "summit_attendee_badge_print_oauth2" => [ + SummitScopes::WriteSummitData, + SummitScopes::UpdateRegistrationOrders + ] + ] + ], + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + tags: ["Summit Badge Prints"], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: "ticket_id", + in: "path", + required: true, + description: "Ticket ID", + schema: new OA\Schema(type: "integer") + ), + ], + responses: [ + new OA\Response(response: Response::HTTP_NO_CONTENT, description: "Badge prints deleted successfully"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Summit or ticket not found"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + ] + )] public function deleteBadgePrints($summit_id, $ticket_id) { return $this->processRequest(function () use ($summit_id, $ticket_id) { $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find(intval($summit_id)); - if (is_null($summit)) return $this->error404(); + if (is_null($summit)) + return $this->error404(); $this->service->deleteBadgePrintsByTicket($summit, intval($ticket_id)); return $this->deleted(); }); } -} \ No newline at end of file +} diff --git a/app/Swagger/Security/SummitAttendeeBadgePrintOAuth2Scheme.php b/app/Swagger/Security/SummitAttendeeBadgePrintOAuth2Scheme.php new file mode 100644 index 000000000..4ff84a652 --- /dev/null +++ b/app/Swagger/Security/SummitAttendeeBadgePrintOAuth2Scheme.php @@ -0,0 +1,27 @@ + 'Write Summit Data', + SummitScopes::UpdateRegistrationOrders => 'Update Registration Orders', + SummitScopes::ReadAllSummitData => 'Read All Summit Data' + ], + ), + ], +) +] +class SummitAttendeeBadgePrintOAuth2Scheme +{ +} diff --git a/app/Swagger/SummitRegistrationPrintSchemas.php b/app/Swagger/SummitRegistrationPrintSchemas.php index 6b3e2f895..09c98a6a0 100644 --- a/app/Swagger/SummitRegistrationPrintSchemas.php +++ b/app/Swagger/SummitRegistrationPrintSchemas.php @@ -4,4 +4,43 @@ use OpenApi\Attributes as OA; -// +// Badge Print Schemas + +#[OA\Schema( + schema: "SummitAttendeeBadgePrint", + description: "Summit Attendee Badge Print", + properties: [ + new OA\Property(property: "id", type: "integer", example: 1), + new OA\Property(property: "created", type: "integer", format: "int64", description: "Creation timestamp (epoch)", example: 1234567890), + new OA\Property(property: "last_edited", type: "integer", format: "int64", description: "Last edit timestamp (epoch)", example: 1234567890), + new OA\Property(property: "print_date", type: "integer", format: "int64", description: "Print timestamp (epoch)", example: 1234567890), + new OA\Property(property: "requestor_id", type: "integer", description: "ID of the member who requested the print", example: 123), + new OA\Property(property: "badge_id", type: "integer", description: "ID of the badge that was printed", example: 456), + new OA\Property(property: "view_type_id", type: "integer", description: "ID of the badge view type used for printing", example: 789), + new OA\Property(property: "view_type_name", type: "string", description: "Name of the badge view type", example: "Standard Badge"), + ], + type: "object" +)] +class SummitAttendeeBadgePrintSchema +{ +} + +#[OA\Schema( + schema: "PaginatedSummitAttendeeBadgePrintsResponse", + description: "Paginated response for Summit Attendee Badge Prints", + properties: [ + new OA\Property(property: "total", type: "integer", example: 100), + new OA\Property(property: "per_page", type: "integer", example: 15), + new OA\Property(property: "current_page", type: "integer", example: 1), + new OA\Property(property: "last_page", type: "integer", example: 7), + new OA\Property( + property: "data", + type: "array", + items: new OA\Items(ref: "#/components/schemas/SummitAttendeeBadgePrint") + ), + ], + type: "object" +)] +class PaginatedSummitAttendeeBadgePrintsResponseSchema +{ +}