Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,13 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\Models\Foundation\Main\IGroup;
use App\Models\Foundation\Summit\Repositories\IPaymentGatewayProfileRepository;
use App\Security\SummitScopes;
use App\Services\Model\IPaymentGatewayProfileService;
use models\oauth2\IResourceServerContext;
use models\summit\ISummitRepository;
use models\summit\Summit;
use models\utils\IEntity;
use ModelSerializers\SerializerRegistry;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\Response;


/**
* Class OAuth2PaymentGatewayProfileApiController
Expand Down Expand Up @@ -49,8 +57,7 @@ public function __construct
ISummitRepository $summit_repository,
IPaymentGatewayProfileService $service,
IResourceServerContext $resource_server_context
)
{
) {
parent::__construct($resource_server_context);
$this->repository = $repository;
$this->summit_repository = $summit_repository;
Expand All @@ -67,6 +74,293 @@ public function __construct

use DeleteSummitChildElement;

// OpenAPI Documentation

#[OA\Get(
path: '/api/v1/summits/{id}/payment-gateway-profiles',
summary: 'Get all payment gateway profiles for a summit',
operationId: 'getAllPaymentGatewayProfiles',
description: 'Retrieves a paginated list of payment gateway profiles configured for a specific summit. Payment profiles manage payment processing for registrations and bookable rooms.',
x: [
'required-groups' => [
IGroup::SuperAdmins,
IGroup::Administrators,
IGroup::SummitAdministrators,
IGroup::SummitRegistrationAdmins,
]
],
security: [
[
'summit_payment_gateway_oauth2' => [
SummitScopes::ReadAllSummitData,
SummitScopes::ReadPaymentProfiles
]
]
],
tags: ['Payment Gateway Profiles'],
parameters: [
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
description: 'Summit ID',
schema: new OA\Schema(type: 'integer')
),
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: 'filter[]',
in: 'query',
required: false,
description: 'Filter expressions. Format: field<op>value. Available fields: application_type (=@, ==), active (==). Operators: == (equals), =@ (starts with)',
style: 'form',
explode: true,
schema: new OA\Schema(
type: 'array',
items: new OA\Items(type: 'string', example: 'application_type==Registration')
)
),
new OA\Parameter(
name: 'order',
in: 'query',
required: false,
description: 'Order by field(s). Available fields: id, application_type. Use "-" prefix for descending order.',
schema: new OA\Schema(type: 'string', example: 'id')
),
],
responses: [
new OA\Response(
response: 200,
description: 'Payment gateway profiles retrieved successfully',
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPaymentGatewayProfilesResponse')
),
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"),
]
)]

#[OA\Get(
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
summary: 'Get a payment gateway profile by ID',
operationId: 'getPaymentGatewayProfile',
description: 'Retrieves detailed information about a specific payment gateway profile.',
x: [
'required-groups' => [
IGroup::SuperAdmins,
IGroup::Administrators,
IGroup::SummitAdministrators,
IGroup::SummitRegistrationAdmins,
]
],
security: [
[
'summit_payment_gateway_oauth2' => [
SummitScopes::ReadAllSummitData,
SummitScopes::ReadPaymentProfiles
]
]
],
tags: ['Payment Gateway Profiles'],
parameters: [
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
description: 'Summit ID',
schema: new OA\Schema(type: 'integer')
),
new OA\Parameter(
name: 'payment_profile_id',
in: 'path',
required: true,
description: 'Payment Gateway Profile ID',
schema: new OA\Schema(type: 'integer')
),
],
responses: [
new OA\Response(
response: 200,
description: 'Payment gateway profile retrieved successfully',
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
),
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"),
]
)]

#[OA\Post(
path: '/api/v1/summits/{id}/payment-gateway-profiles',
summary: 'Create a new payment gateway profile',
operationId: 'createPaymentGatewayProfile',
description: 'Creates a new payment gateway profile for the summit. Supports Stripe and LawPay providers.',
x: [
'required-groups' => [
IGroup::SuperAdmins,
IGroup::Administrators,
IGroup::SummitAdministrators,
IGroup::SummitRegistrationAdmins,
]
],
security: [
[
'summit_payment_gateway_oauth2' => [
SummitScopes::WriteSummitData,
SummitScopes::WritePaymentProfiles
]
]
],
tags: ['Payment Gateway Profiles'],
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/PaymentGatewayProfileCreateRequest')
),
responses: [
new OA\Response(
response: 201,
description: 'Payment gateway profile created successfully',
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
),
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"),
]
)]

#[OA\Put(
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
summary: 'Update a payment gateway profile',
operationId: 'updatePaymentGatewayProfile',
description: 'Updates an existing payment gateway profile.',
x: [
'required-groups' => [
IGroup::SuperAdmins,
IGroup::Administrators,
IGroup::SummitAdministrators,
IGroup::SummitRegistrationAdmins,
]
],
security: [
[
'summit_payment_gateway_oauth2' => [
SummitScopes::WriteSummitData,
SummitScopes::WritePaymentProfiles
]
]
],
tags: ['Payment Gateway Profiles'],
parameters: [
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
description: 'Summit ID',
schema: new OA\Schema(type: 'integer')
),
new OA\Parameter(
name: 'payment_profile_id',
in: 'path',
required: true,
description: 'Payment Gateway Profile ID',
schema: new OA\Schema(type: 'integer')
),
],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfileUpdateRequest')
),
responses: [
new OA\Response(
response: 200,
description: 'Payment gateway profile updated successfully',
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
),
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"),
]
)]

#[OA\Delete(
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
summary: 'Delete a payment gateway profile',
operationId: 'deletePaymentGatewayProfile',
description: 'Deletes an existing payment gateway profile from the summit.',
x: [
'required-groups' => [
IGroup::SuperAdmins,
IGroup::Administrators,
IGroup::SummitAdministrators,
IGroup::SummitRegistrationAdmins,
]
],
security: [
[
'summit_payment_gateway_oauth2' => [
SummitScopes::WriteSummitData,
SummitScopes::WritePaymentProfiles
]
]
],
tags: ['Payment Gateway Profiles'],
parameters: [
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
description: 'Summit ID',
schema: new OA\Schema(type: 'integer')
),
new OA\Parameter(
name: 'payment_profile_id',
in: 'path',
required: true,
description: 'Payment Gateway Profile ID',
schema: new OA\Schema(type: 'integer')
),
],
responses: [
new OA\Response(
response: 204,
description: 'Payment gateway profile deleted successfully'
),
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"),
]
)]

/**
* @return ISummitRepository
*/
Expand Down Expand Up @@ -126,46 +420,52 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
/**
* @return array
*/
protected function getFilterRules():array
protected function getFilterRules(): array
{
return [
'application_type' => ['=@', '=='],
'active' => ['=='],
'active' => ['=='],
];
}

/**
* @return array
*/
protected function getFilterValidatorRules():array{
protected function getFilterValidatorRules(): array
{
return [
'application_type' => 'sometimes|required|string',
'active' => 'sometimes|required|boolean',
'active' => 'sometimes|required|boolean',
];
}
/**
* @return array
*/
protected function getOrderRules():array{
protected function getOrderRules(): array
{
return [
'id',
'application_type',
];
}

protected function serializerType():string{
protected function serializerType(): string
{
return SerializerRegistry::SerializerType_Private;
}

protected function addSerializerType():string{
protected function addSerializerType(): string
{
return SerializerRegistry::SerializerType_Private;
}

protected function updateSerializerType():string{
protected function updateSerializerType(): string
{
return SerializerRegistry::SerializerType_Private;
}

public function getChildSerializer(){
public function getChildSerializer()
{
return SerializerRegistry::SerializerType_Private;
}
}
}
Loading