1- <?php namespace App \Http \Controllers ;
1+ <?php
2+
3+ namespace App \Http \Controllers ;
4+
25/*
36 * Copyright 2023 OpenStack Foundation
47 * Licensed under the Apache License, Version 2.0 (the "License");
1316 **/
1417
1518use App \Http \Utils \EpochCellFormatter ;
19+ use App \Models \Foundation \Main \IGroup ;
1620use App \Models \Foundation \Summit \Repositories \ISummitAttendeeBadgePrintRepository ;
21+ use App \Security \SummitScopes ;
22+ use App \Swagger \Security \BadgePrintsAuthSchema ;
23+ use Illuminate \Http \Response ;
1724use models \oauth2 \IResourceServerContext ;
1825use models \summit \ISummitRepository ;
1926use ModelSerializers \SerializerRegistry ;
27+ use OpenApi \Attributes as OA ;
2028use services \model \ISummitAttendeeBadgePrintService ;
2129use utils \Filter ;
2230use utils \FilterElement ;
2533 * Class OAuth2SummitAttendeeBadgePrintApiController
2634 * @package App\Http\Controllers
2735 */
28- final class OAuth2SummitAttendeeBadgePrintApiController
29- extends OAuth2ProtectedController
36+ final class OAuth2SummitAttendeeBadgePrintApiController extends OAuth2ProtectedController
3037{
3138 /**
3239 * @var ISummitAttendeeBadgePrintService
@@ -35,12 +42,11 @@ final class OAuth2SummitAttendeeBadgePrintApiController
3542
3643 public function __construct
3744 (
38- ISummitRepository $ summit_repository ,
45+ ISummitRepository $ summit_repository ,
3946 ISummitAttendeeBadgePrintRepository $ repository ,
40- ISummitAttendeeBadgePrintService $ service ,
41- IResourceServerContext $ resource_server_context
42- )
43- {
47+ ISummitAttendeeBadgePrintService $ service ,
48+ IResourceServerContext $ resource_server_context
49+ ) {
4450 parent ::__construct ($ resource_server_context );
4551 $ this ->repository = $ repository ;
4652 $ this ->summit_repository = $ summit_repository ;
@@ -49,28 +55,114 @@ public function __construct
4955
5056 use ParametrizedGetAll;
5157
58+ #[OA \Get(
59+ path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints " ,
60+ operationId: "getAllBadgePrintsByTicket " ,
61+ summary: "Get all badge prints for a ticket " ,
62+ description: "Returns a paginated list of badge print records for a specific ticket. Allows ordering, filtering and pagination. " ,
63+ security: [
64+ [
65+ "summit_attendee_badge_print_oauth2 " => [
66+ SummitScopes::ReadAllSummitData
67+ ]
68+ ]
69+ ],
70+ x: [
71+ 'required-groups ' => [
72+ IGroup::SuperAdmins,
73+ IGroup::Administrators,
74+ IGroup::SummitAdministrators,
75+ IGroup::SummitRegistrationAdmins,
76+ ]
77+ ],
78+ tags: ["Summit Badge Prints " ],
79+ parameters: [
80+ new OA \Parameter (
81+ name: 'id ' ,
82+ in: 'path ' ,
83+ required: true ,
84+ schema: new OA \Schema (type: 'integer ' ),
85+ description: 'The summit id '
86+ ),
87+ new OA \Parameter (
88+ name: 'page ' ,
89+ in: 'query ' ,
90+ required: false ,
91+ schema: new OA \Schema (type: 'integer ' ),
92+ description: 'The page number '
93+ ),
94+ new OA \Parameter (
95+ name: 'page_size ' ,
96+ in: 'query ' ,
97+ required: false ,
98+ schema: new OA \Schema (type: 'integer ' ),
99+ description: 'The number of pages in each page ' ,
100+ ),
101+ new OA \Parameter (
102+ name: "ticket_id " ,
103+ in: "path " ,
104+ required: true ,
105+ description: "Ticket ID " ,
106+ schema: new OA \Schema (type: "integer " )
107+ ),
108+ new OA \Parameter (
109+ name: "filter[] " ,
110+ in: "query " ,
111+ required: false ,
112+ description: "Filter badge prints. Available filters: id==, view_type_id==, created (>, <, <=, >=, ==, []), print_date (>, <, <=, >=, ==, []), requestor_full_name (==, @@, =@), requestor_email (==, @@, =@) " ,
113+ schema: new OA \Schema (type: "array " , items: new OA \Items (type: "string " )),
114+ explode: true
115+ ),
116+ new OA \Parameter (
117+ name: "order " ,
118+ in: "query " ,
119+ required: false ,
120+ description: "Order by field. Valid fields: id, created, view_type_id, print_date, requestor_full_name, requestor_email " ,
121+ schema: new OA \Schema (type: "string " )
122+ ),
123+ new OA \Parameter (
124+ name: "expand " ,
125+ in: "query " ,
126+ required: false ,
127+ description: "Expand related entities. Available expansions: requestor, badge, view_type " ,
128+ schema: new OA \Schema (type: "string " )
129+ ),
130+ ],
131+ responses: [
132+ new OA \Response (
133+ response: Response::HTTP_OK ,
134+ description: "Success " ,
135+ content: new OA \JsonContent (ref: "#/components/schemas/PaginatedSummitAttendeeBadgePrintsResponse " )
136+ ),
137+ new OA \Response (response: Response::HTTP_NOT_FOUND , description: "Summit or ticket not found " ),
138+ new OA \Response (response: Response::HTTP_UNAUTHORIZED , description: "Unauthorized " ),
139+ new OA \Response (response: Response::HTTP_FORBIDDEN , description: "Forbidden " ),
140+ new OA \Response (response: Response::HTTP_BAD_REQUEST , description: "Invalid filter or order parameter " ),
141+ ]
142+ )]
52143 public function getAllBySummitAndTicket ($ summit_id , $ ticket_id )
53144 {
54145 $ summit = SummitFinderStrategyFactory::build ($ this ->summit_repository , $ this ->getResourceServerContext ())->find ($ summit_id );
55- if (is_null ($ summit )) return $ this ->error404 ();
146+ if (is_null ($ summit ))
147+ return $ this ->error404 ();
56148
57149 return $ this ->_getAll (
58150 function () {
59151 return [
60- 'id ' => ['== ' ],
61- 'view_type_id ' => ['== ' ],
62- 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
63- 'print_date ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
64- 'requestor_full_name ' => ['== ' ,'@@ ' ,'=@ ' ],
65- 'requestor_email ' => ['== ' ,'@@ ' ,'=@ ' ],
152+ 'id ' => ['== ' ],
153+ 'view_type_id ' => ['== ' ],
154+ 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
155+ 'print_date ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
156+ 'requestor_full_name ' => ['== ' , '@@ ' , '=@ ' ],
157+ 'requestor_email ' => ['== ' , '@@ ' , '=@ ' ],
66158 ];
67159 },
68160 function () {
69161 return [
70162 'id ' => 'sometimes|integer ' ,
71163 'view_type_id ' => 'sometimes|integer ' ,
72- 'created ' => 'sometimes|date_format:U|epoch_seconds ' ,
73- 'print_date ' => 'sometimes|date_format:U|epoch_seconds ' ,
164+ 'created ' => 'sometimes|date_format:U|epoch_seconds ' ,
165+ 'print_date ' => 'sometimes|date_format:U|epoch_seconds ' ,
74166 'requestor_full_name ' => 'sometimes|string ' ,
75167 'requestor_email ' => 'sometimes|string ' ,
76168 ];
@@ -95,28 +187,96 @@ function ($filter) use ($summit, $ticket_id) {
95187 );
96188 }
97189
190+ #[OA \Get(
191+ path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints/csv " ,
192+ operationId: "getAllBadgePrintsByTicketCSV " ,
193+ summary: "Export badge prints to CSV " ,
194+ description: "Exports all badge print records for a specific ticket to CSV format. Allows ordering and filtering. " ,
195+ security: [
196+ [
197+ "summit_attendee_badge_print_oauth2 " => [
198+ SummitScopes::ReadAllSummitData
199+ ]
200+ ]
201+ ],
202+ x: [
203+ 'required-groups ' => [
204+ IGroup::SuperAdmins,
205+ IGroup::Administrators,
206+ IGroup::SummitAdministrators,
207+ IGroup::SummitRegistrationAdmins,
208+ ]
209+ ],
210+ tags: ["Summit Badge Prints " ],
211+ parameters: [
212+ new OA \Parameter (
213+ name: 'id ' ,
214+ in: 'path ' ,
215+ required: true ,
216+ schema: new OA \Schema (type: 'integer ' ),
217+ description: 'The summit id '
218+ ),
219+ new OA \Parameter (
220+ name: "ticket_id " ,
221+ in: "path " ,
222+ required: true ,
223+ description: "Ticket ID " ,
224+ schema: new OA \Schema (type: "integer " )
225+ ),
226+ new OA \Parameter (
227+ name: "filter[] " ,
228+ in: "query " ,
229+ required: false ,
230+ description: "Filter badge prints. Available filters: id==, view_type_id==, created (>, <, <=, >=, ==, []), print_date (>, <, <=, >=, ==, []), requestor_full_name (==, @@, =@), requestor_email (==, @@, =@) " ,
231+ schema: new OA \Schema (type: "array " , items: new OA \Items (type: "string " )),
232+ explode: true
233+ ),
234+ new OA \Parameter (
235+ name: "order " ,
236+ in: "query " ,
237+ required: false ,
238+ description: "Order by field. Valid fields: id, created, view_type_id, print_date, requestor_full_name, requestor_email " ,
239+ schema: new OA \Schema (type: "string " )
240+ ),
241+ ],
242+ responses: [
243+ new OA \Response (
244+ response: Response::HTTP_OK ,
245+ description: "CSV file " ,
246+ content: new OA \MediaType (
247+ mediaType: "text/csv " ,
248+ schema: new OA \Schema (type: "string " , format: "binary " )
249+ )
250+ ),
251+ new OA \Response (response: Response::HTTP_NOT_FOUND , description: "Summit or ticket not found " ),
252+ new OA \Response (response: Response::HTTP_UNAUTHORIZED , description: "Unauthorized " ),
253+ new OA \Response (response: Response::HTTP_FORBIDDEN , description: "Forbidden " ),
254+ new OA \Response (response: Response::HTTP_BAD_REQUEST , description: "Invalid filter or order parameter " ),
255+ ]
256+ )]
98257 public function getAllBySummitAndTicketCSV ($ summit_id , $ ticket_id )
99258 {
100259 $ summit = SummitFinderStrategyFactory::build ($ this ->summit_repository , $ this ->getResourceServerContext ())->find ($ summit_id );
101- if (is_null ($ summit )) return $ this ->error404 ();
260+ if (is_null ($ summit ))
261+ return $ this ->error404 ();
102262
103263 return $ this ->_getAllCSV (
104264 function () {
105265 return [
106- 'id ' => ['== ' ],
107- 'view_type_id ' => ['== ' ],
108- 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
109- 'print_date ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
110- 'requestor_full_name ' => ['== ' ,'@@ ' ,'=@ ' ],
111- 'requestor_email ' => ['== ' ,'@@ ' ,'=@ ' ],
266+ 'id ' => ['== ' ],
267+ 'view_type_id ' => ['== ' ],
268+ 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
269+ 'print_date ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
270+ 'requestor_full_name ' => ['== ' , '@@ ' , '=@ ' ],
271+ 'requestor_email ' => ['== ' , '@@ ' , '=@ ' ],
112272 ];
113273 },
114274 function () {
115275 return [
116276 'id ' => 'sometimes|integer ' ,
117277 'view_type_id ' => 'sometimes|integer ' ,
118- 'created ' => 'sometimes|date_format:U|epoch_seconds ' ,
119- 'print_date ' => 'sometimes|date_format:U|epoch_seconds ' ,
278+ 'created ' => 'sometimes|date_format:U|epoch_seconds ' ,
279+ 'print_date ' => 'sometimes|date_format:U|epoch_seconds ' ,
120280 'requestor_full_name ' => 'sometimes|string ' ,
121281 'requestor_email ' => 'sometimes|string ' ,
122282 ];
@@ -155,20 +315,61 @@ function () {
155315 );
156316 }
157317
158- /**
159- * @param $summit_id
160- * @param $ticket_id
161- * @return \Illuminate\Http\JsonResponse|mixed
162- */
318+ #[OA \Delete(
319+ path: "/api/v1/summits/{id}/tickets/{ticket_id}/badge/current/prints " ,
320+ operationId: "deleteBadgePrintsByTicket " ,
321+ summary: "Delete all badge prints for a ticket " ,
322+ description: "Deletes all badge print records for a specific ticket " ,
323+ security: [
324+ [
325+ "summit_attendee_badge_print_oauth2 " => [
326+ SummitScopes::WriteSummitData,
327+ SummitScopes::UpdateRegistrationOrders
328+ ]
329+ ]
330+ ],
331+ x: [
332+ 'required-groups ' => [
333+ IGroup::SuperAdmins,
334+ IGroup::Administrators,
335+ IGroup::SummitAdministrators,
336+ IGroup::SummitRegistrationAdmins,
337+ ]
338+ ],
339+ tags: ["Summit Badge Prints " ],
340+ parameters: [
341+ new OA \Parameter (
342+ name: 'id ' ,
343+ in: 'path ' ,
344+ required: true ,
345+ schema: new OA \Schema (type: 'integer ' ),
346+ description: 'The summit id '
347+ ),
348+ new OA \Parameter (
349+ name: "ticket_id " ,
350+ in: "path " ,
351+ required: true ,
352+ description: "Ticket ID " ,
353+ schema: new OA \Schema (type: "integer " )
354+ ),
355+ ],
356+ responses: [
357+ new OA \Response (response: Response::HTTP_NO_CONTENT , description: "Badge prints deleted successfully " ),
358+ new OA \Response (response: Response::HTTP_NOT_FOUND , description: "Summit or ticket not found " ),
359+ new OA \Response (response: Response::HTTP_UNAUTHORIZED , description: "Unauthorized " ),
360+ new OA \Response (response: Response::HTTP_FORBIDDEN , description: "Forbidden " ),
361+ ]
362+ )]
163363 public function deleteBadgePrints ($ summit_id , $ ticket_id )
164364 {
165365 return $ this ->processRequest (function () use ($ summit_id , $ ticket_id ) {
166366 $ summit = SummitFinderStrategyFactory::build ($ this ->summit_repository , $ this ->getResourceServerContext ())->find (intval ($ summit_id ));
167- if (is_null ($ summit )) return $ this ->error404 ();
367+ if (is_null ($ summit ))
368+ return $ this ->error404 ();
168369
169370 $ this ->service ->deleteBadgePrintsByTicket ($ summit , intval ($ ticket_id ));
170371
171372 return $ this ->deleted ();
172373 });
173374 }
174- }
375+ }
0 commit comments