diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSponsorshipTypeApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSponsorshipTypeApiController.php index a08a52a9d..dcce2b47f 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSponsorshipTypeApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitSponsorshipTypeApiController.php @@ -1,4 +1,7 @@ -service = $service; $this->repository = $repository; $this->summit_repository = $summit_repository; @@ -69,6 +74,221 @@ public function __construct use DeleteSummitChildElement; + #[OA\Get( + path: '/api/v1/summits/{id}/sponsorships-types', + summary: 'Get all sponsorship types for a summit', + operationId: 'getSummitAllSponsorshipTypes', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::ReadSummitData, + SummitScopes::ReadAllSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'page', in: 'query', required: false, description: 'Page number', schema: new OA\Schema(type: 'integer', default: 1)), + new OA\Parameter(name: 'per_page', in: 'query', required: false, description: 'Items per page', schema: new OA\Schema(type: 'integer', default: 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 name, label, or size (name=@value, label==value, size=@value)', schema: new OA\Schema(type: 'string')), + new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-name, +/-order, +/-label, +/-size', schema: new OA\Schema(type: 'string')), + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Successful response', + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedSummitSponsorshipTypesResponse') + ), + 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) + { + return parent::getAllBySummit($summit_id); + } + + #[OA\Post( + path: '/api/v1/summits/{id}/sponsorships-types', + summary: 'Create a new sponsorship type', + operationId: 'createSummitSponsorshipType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits Sponsorship 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/SummitSponsorshipTypeCreateRequest') + ), + responses: [ + new OA\Response( + response: Response::HTTP_CREATED, + description: 'Sponsorship type created', + content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipType') + ), + 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); + } + + #[OA\Get( + path: '/api/v1/summits/{id}/sponsorships-types/{type_id}', + summary: 'Get a sponsorship type by ID', + operationId: 'getSummitSponsorshipType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::ReadSummitData, + SummitScopes::ReadAllSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship 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/SummitSponsorshipType') + ), + 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, $type_id) + { + return parent::get($summit_id, $type_id); + } + + #[OA\Put( + path: '/api/v1/summits/{id}/sponsorships-types/{type_id}', + summary: 'Update a sponsorship type', + operationId: 'updateSummitSponsorshipType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipTypeUpdateRequest') + ), + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Sponsorship type updated', + content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipType') + ), + 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, $type_id) + { + return parent::update($summit_id, $type_id); + } + + #[OA\Delete( + path: '/api/v1/summits/{id}/sponsorships-types/{type_id}', + summary: 'Delete a sponsorship type', + operationId: 'deleteSummitSponsorshipType', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship 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, $type_id) + { + return parent::delete($summit_id, $type_id); + } + /** * @return array */ @@ -151,7 +371,7 @@ protected function deleteChild(Summit $summit, $child_id): void */ protected function getChildFromSummit(Summit $summit, $child_id): ?IEntity { - return $summit->getSummitSponsorshipTypeById(intval($child_id)); + return $summit->getSummitSponsorshipTypeById(intval($child_id)); } /** @@ -171,7 +391,7 @@ function getUpdateValidationRules(array $payload): array */ protected function updateChild(Summit $summit, int $child_id, array $payload): IEntity { - return $this->service->update($summit,$child_id, $payload); + return $this->service->update($summit, $child_id, $payload); } use RequestProcessor; @@ -184,11 +404,68 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I * @throws \models\exceptions\EntityNotFoundException * @throws \models\exceptions\ValidationException */ - public function addBadgeImage(LaravelRequest $request, $summit_id, $type_id){ + #[OA\Post( + path: '/api/v1/summits/{id}/sponsorships-types/{type_id}/badge-image', + summary: 'Upload a badge image for a sponsorship type', + operationId: 'addSummitSponsorshipTypeBadgeImage', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\MediaType( + mediaType: 'multipart/form-data', + schema: new OA\Schema( + required: ['file'], + properties: [ + new OA\Property(property: 'file', type: 'string', format: 'binary', description: 'Image file to upload') + ] + ) + ) + ), + responses: [ + new OA\Response( + response: Response::HTTP_CREATED, + description: 'Badge image uploaded successfully', + content: new OA\JsonContent( + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 123), + new OA\Property(property: 'url', type: 'string', example: 'https://example.com/badge.png'), + new OA\Property(property: 'filename', type: 'string', example: 'badge.png'), + ] + ) + ), + 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 addBadgeImage(LaravelRequest $request, $summit_id, $type_id) + { return $this->processRequest(function () use ($request, $summit_id, $type_id) { $summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->resource_server_context)->find($summit_id); - if (is_null($summit)) return $this->error404(); + if (is_null($summit)) + return $this->error404(); $file = $request->file('file'); if (is_null($file)) { @@ -214,11 +491,45 @@ public function addBadgeImage(LaravelRequest $request, $summit_id, $type_id){ * @throws \models\exceptions\EntityNotFoundException * @throws \models\exceptions\ValidationException */ - public function removeBadgeImage($summit_id, $type_id){ + #[OA\Delete( + path: '/api/v1/summits/{id}/sponsorships-types/{type_id}/badge-image', + summary: 'Remove the badge image from a sponsorship type', + operationId: 'deleteSummitSponsorshipTypeBadgeImage', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + ] + ], + security: [ + [ + 'sponsorship_types_oauth2' => [ + SummitScopes::WriteSummitData, + ] + ] + ], + tags: ['Summits Sponsorship Types'], + parameters: [ + new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')), + new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship 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 removeBadgeImage($summit_id, $type_id) + { return $this->processRequest(function () use ($summit_id, $type_id) { $summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->resource_server_context)->find($summit_id); - if (is_null($summit)) return $this->error404(); + if (is_null($summit)) + return $this->error404(); $this->service->deleteBadgeImage($summit, $type_id); @@ -226,4 +537,4 @@ public function removeBadgeImage($summit_id, $type_id){ }); } -} \ No newline at end of file +} diff --git a/app/Swagger/Security/SponsorshipTypesAuthSchema.php b/app/Swagger/Security/SponsorshipTypesAuthSchema.php new file mode 100644 index 000000000..8fb621eb7 --- /dev/null +++ b/app/Swagger/Security/SponsorshipTypesAuthSchema.php @@ -0,0 +1,28 @@ + 'Read Summit Data', + SummitScopes::ReadAllSummitData => 'Read All Summit Data', + SummitScopes::WriteSummitData => 'Write Summit Data', + ], + ), + ], +) +] +class SponsorshipTypesAuthSchema +{ +} diff --git a/app/Swagger/SummitSchemas.php b/app/Swagger/SummitSchemas.php index 5f83d1c19..78d9f4fbd 100644 --- a/app/Swagger/SummitSchemas.php +++ b/app/Swagger/SummitSchemas.php @@ -2,7 +2,9 @@ namespace App\Swagger\schemas; +use models\summit\ISponsorshipTypeConstants; use OpenApi\Attributes as OA; + #[OA\Schema( schema: 'SummitScheduleConfigContent', type: 'object', @@ -341,6 +343,49 @@ class SummitAttendeeBadgeSchema )] class PaginatedSummitAttendeeBadgesResponseSchema {} + +#[OA\Schema( + schema: 'PaginatedSummitSponsorshipTypesResponse', + 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/SummitSponsorshipType') + ) + ] + ) + ] +)] +class PaginatedSummitSponsorshipTypesResponseSchema {} + +#[OA\Schema( + schema: 'SummitSponsorshipTypeCreateRequest', + type: 'object', + required: ['name', 'label', 'size'], + properties: [ + new OA\Property(property: 'name', type: 'string', example: 'platinum'), + new OA\Property(property: 'label', type: 'string', example: 'Platinum'), + new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes), + ] +)] +class SummitSponsorshipTypeCreateRequestSchema {} + +#[OA\Schema( + schema: 'SummitSponsorshipTypeUpdateRequest', + type: 'object', + properties: [ + new OA\Property(property: 'name', type: 'string', example: 'platinum'), + new OA\Property(property: 'label', type: 'string', example: 'Platinum'), + new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes), + new OA\Property(property: 'order', type: 'integer', example: 1, minimum: 1), + ] +)] +class SummitSponsorshipTypeUpdateRequestSchema {} + #[OA\Schema( schema: 'SummitMediaFileType', type: 'object', diff --git a/app/Swagger/SummitSponsorshipSchemas.php b/app/Swagger/SummitSponsorshipSchemas.php index e7ee8acfe..b17bcd16a 100644 --- a/app/Swagger/SummitSponsorshipSchemas.php +++ b/app/Swagger/SummitSponsorshipSchemas.php @@ -79,29 +79,3 @@ class AddAddOnRequestSchema {} ] )] class UpdateAddOnRequestSchema {} - -#[OA\Schema( - title: "Summit Sponsorship Type", - description: "Summit Sponsorship Type Schema", - type: "object", - properties: [ - new OA\Property(property: "id", type: "integer", format: "int64"), - new OA\Property(property: "widget_title", type: "string"), - new OA\Property(property: "lobby_template", type: "string"), - new OA\Property(property: "expo_hall_template", type: "string"), - new OA\Property(property: "sponsor_page_template", type: "string"), - new OA\Property(property: "event_page_template", type: "string"), - new OA\Property(property: "sponsor_page_use_disqus_widget", type: "boolean"), - new OA\Property(property: "sponsor_page_use_live_event_widget", type: "boolean"), - new OA\Property(property: "sponsor_page_use_schedule_widget", type: "boolean"), - new OA\Property(property: "sponsor_page_use_banner_widget", type: "boolean"), - new OA\Property(property: "type_id", type: "integer", format: "int64"), - new OA\Property(property: "badge_image", type: "string"), - new OA\Property(property: "badge_image_alt_text", type: "string"), - new OA\Property(property: "summit_id", type: "integer", format: "int64"), - new OA\Property(property: "order", type: "integer", format: "int32"), - new OA\Property(property: "should_display_on_expo_hall_page", type: "boolean"), - new OA\Property(property: "should_display_on_lobby_page", type: "boolean"), - ] -)] -class SummitSponsorshipTypeSchemas {}