Skip to content

Commit fa9e1cd

Browse files
feat: Extend Swagger Coverage for controller Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php
1 parent dacf697 commit fa9e1cd

2 files changed

Lines changed: 290 additions & 1 deletion

File tree

app/Http/Controllers/Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php

Lines changed: 218 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
* limitations under the License.
1313
**/
1414
use App\Models\Foundation\Summit\Repositories\IPaymentGatewayProfileRepository;
15+
use App\Security\SummitScopes;
1516
use App\Services\Model\IPaymentGatewayProfileService;
1617
use models\oauth2\IResourceServerContext;
1718
use models\summit\ISummitRepository;
1819
use models\summit\Summit;
1920
use models\utils\IEntity;
2021
use ModelSerializers\SerializerRegistry;
22+
use OpenApi\Attributes as OA;
2123

2224
/**
2325
* Class OAuth2PaymentGatewayProfileApiController
@@ -67,6 +69,221 @@ public function __construct
6769

6870
use DeleteSummitChildElement;
6971

72+
// OpenAPI Documentation
73+
74+
#[OA\Get(
75+
path: '/api/v1/summits/{id}/payment-gateway-profiles',
76+
summary: 'Get all payment gateway profiles for a summit',
77+
description: 'Retrieves a paginated list of payment gateway profiles configured for a specific summit. Payment profiles manage payment processing for registrations and bookable rooms.',
78+
security: [['oauth2_security_scope' => [SummitScopes::ReadAllSummitData]]],
79+
tags: ['Payment Gateway Profiles'],
80+
parameters: [
81+
new OA\Parameter(
82+
name: 'id',
83+
in: 'path',
84+
required: true,
85+
description: 'Summit ID',
86+
schema: new OA\Schema(type: 'integer')
87+
),
88+
new OA\Parameter(
89+
name: 'page',
90+
in: 'query',
91+
required: false,
92+
description: 'Page number for pagination',
93+
schema: new OA\Schema(type: 'integer', example: 1)
94+
),
95+
new OA\Parameter(
96+
name: 'per_page',
97+
in: 'query',
98+
required: false,
99+
description: 'Items per page',
100+
schema: new OA\Schema(type: 'integer', example: 10, maximum: 100)
101+
),
102+
new OA\Parameter(
103+
name: 'filter[]',
104+
in: 'query',
105+
required: false,
106+
description: 'Filter expressions. Format: field<op>value. Available fields: application_type (=@, ==), active (==). Operators: == (equals), =@ (starts with)',
107+
style: 'form',
108+
explode: true,
109+
schema: new OA\Schema(
110+
type: 'array',
111+
items: new OA\Items(type: 'string', example: 'application_type==Registration')
112+
)
113+
),
114+
new OA\Parameter(
115+
name: 'order',
116+
in: 'query',
117+
required: false,
118+
description: 'Order by field(s). Available fields: id, application_type. Use "-" prefix for descending order.',
119+
schema: new OA\Schema(type: 'string', example: 'id')
120+
),
121+
],
122+
responses: [
123+
new OA\Response(
124+
response: 200,
125+
description: 'Payment gateway profiles retrieved successfully',
126+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPaymentGatewayProfilesResponse')
127+
),
128+
new OA\Response(response: 400, ref: '#/components/responses/400'),
129+
new OA\Response(response: 401, ref: '#/components/responses/401'),
130+
new OA\Response(response: 403, ref: '#/components/responses/403'),
131+
new OA\Response(response: 404, ref: '#/components/responses/404'),
132+
new OA\Response(response: 412, ref: '#/components/responses/412'),
133+
new OA\Response(response: 500, ref: '#/components/responses/500'),
134+
]
135+
)]
136+
137+
#[OA\Get(
138+
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
139+
summary: 'Get a payment gateway profile by ID',
140+
description: 'Retrieves detailed information about a specific payment gateway profile.',
141+
security: [['oauth2_security_scope' => [SummitScopes::ReadAllSummitData]]],
142+
tags: ['Payment Gateway Profiles'],
143+
parameters: [
144+
new OA\Parameter(
145+
name: 'id',
146+
in: 'path',
147+
required: true,
148+
description: 'Summit ID',
149+
schema: new OA\Schema(type: 'integer')
150+
),
151+
new OA\Parameter(
152+
name: 'payment_profile_id',
153+
in: 'path',
154+
required: true,
155+
description: 'Payment Gateway Profile ID',
156+
schema: new OA\Schema(type: 'integer')
157+
),
158+
],
159+
responses: [
160+
new OA\Response(
161+
response: 200,
162+
description: 'Payment gateway profile retrieved successfully',
163+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
164+
),
165+
new OA\Response(response: 400, ref: '#/components/responses/400'),
166+
new OA\Response(response: 401, ref: '#/components/responses/401'),
167+
new OA\Response(response: 403, ref: '#/components/responses/403'),
168+
new OA\Response(response: 404, ref: '#/components/responses/404'),
169+
new OA\Response(response: 412, ref: '#/components/responses/412'),
170+
new OA\Response(response: 500, ref: '#/components/responses/500'),
171+
]
172+
)]
173+
174+
#[OA\Post(
175+
path: '/api/v1/summits/{id}/payment-gateway-profiles',
176+
summary: 'Create a new payment gateway profile',
177+
description: 'Creates a new payment gateway profile for the summit. Supports Stripe and LawPay providers.',
178+
security: [['oauth2_security_scope' => [SummitScopes::WriteSummitData]]],
179+
tags: ['Payment Gateway Profiles'],
180+
parameters: [
181+
new OA\Parameter(
182+
name: 'id',
183+
in: 'path',
184+
required: true,
185+
description: 'Summit ID',
186+
schema: new OA\Schema(type: 'integer')
187+
),
188+
],
189+
requestBody: new OA\RequestBody(
190+
required: true,
191+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfileCreateRequest')
192+
),
193+
responses: [
194+
new OA\Response(
195+
response: 201,
196+
description: 'Payment gateway profile created successfully',
197+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
198+
),
199+
new OA\Response(response: 400, ref: '#/components/responses/400'),
200+
new OA\Response(response: 401, ref: '#/components/responses/401'),
201+
new OA\Response(response: 403, ref: '#/components/responses/403'),
202+
new OA\Response(response: 404, ref: '#/components/responses/404'),
203+
new OA\Response(response: 412, ref: '#/components/responses/412'),
204+
new OA\Response(response: 422, ref: '#/components/responses/422'),
205+
new OA\Response(response: 500, ref: '#/components/responses/500'),
206+
]
207+
)]
208+
209+
#[OA\Put(
210+
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
211+
summary: 'Update a payment gateway profile',
212+
description: 'Updates an existing payment gateway profile.',
213+
security: [['oauth2_security_scope' => [SummitScopes::WriteSummitData]]],
214+
tags: ['Payment Gateway Profiles'],
215+
parameters: [
216+
new OA\Parameter(
217+
name: 'id',
218+
in: 'path',
219+
required: true,
220+
description: 'Summit ID',
221+
schema: new OA\Schema(type: 'integer')
222+
),
223+
new OA\Parameter(
224+
name: 'payment_profile_id',
225+
in: 'path',
226+
required: true,
227+
description: 'Payment Gateway Profile ID',
228+
schema: new OA\Schema(type: 'integer')
229+
),
230+
],
231+
requestBody: new OA\RequestBody(
232+
required: true,
233+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfileUpdateRequest')
234+
),
235+
responses: [
236+
new OA\Response(
237+
response: 200,
238+
description: 'Payment gateway profile updated successfully',
239+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile')
240+
),
241+
new OA\Response(response: 400, ref: '#/components/responses/400'),
242+
new OA\Response(response: 401, ref: '#/components/responses/401'),
243+
new OA\Response(response: 403, ref: '#/components/responses/403'),
244+
new OA\Response(response: 404, ref: '#/components/responses/404'),
245+
new OA\Response(response: 412, ref: '#/components/responses/412'),
246+
new OA\Response(response: 422, ref: '#/components/responses/422'),
247+
new OA\Response(response: 500, ref: '#/components/responses/500'),
248+
]
249+
)]
250+
251+
#[OA\Delete(
252+
path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}',
253+
summary: 'Delete a payment gateway profile',
254+
description: 'Deletes an existing payment gateway profile from the summit.',
255+
security: [['oauth2_security_scope' => [SummitScopes::WriteSummitData]]],
256+
tags: ['Payment Gateway Profiles'],
257+
parameters: [
258+
new OA\Parameter(
259+
name: 'id',
260+
in: 'path',
261+
required: true,
262+
description: 'Summit ID',
263+
schema: new OA\Schema(type: 'integer')
264+
),
265+
new OA\Parameter(
266+
name: 'payment_profile_id',
267+
in: 'path',
268+
required: true,
269+
description: 'Payment Gateway Profile ID',
270+
schema: new OA\Schema(type: 'integer')
271+
),
272+
],
273+
responses: [
274+
new OA\Response(
275+
response: 204,
276+
description: 'Payment gateway profile deleted successfully'
277+
),
278+
new OA\Response(response: 400, ref: '#/components/responses/400'),
279+
new OA\Response(response: 401, ref: '#/components/responses/401'),
280+
new OA\Response(response: 403, ref: '#/components/responses/403'),
281+
new OA\Response(response: 404, ref: '#/components/responses/404'),
282+
new OA\Response(response: 412, ref: '#/components/responses/412'),
283+
new OA\Response(response: 500, ref: '#/components/responses/500'),
284+
]
285+
)]
286+
70287
/**
71288
* @return ISummitRepository
72289
*/
@@ -168,4 +385,4 @@ protected function updateSerializerType():string{
168385
public function getChildSerializer(){
169386
return SerializerRegistry::SerializerType_Private;
170387
}
171-
}
388+
}

app/Swagger/schemas.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,75 @@ class UserStorySchema {}
398398
]
399399
)]
400400
class PaginatedUserStoriesResponseSchema {}
401+
402+
#[OA\Schema(
403+
schema: 'PaymentGatewayProfile',
404+
type: 'object',
405+
properties: [
406+
new OA\Property(property: 'id', type: 'integer', example: 1),
407+
new OA\Property(property: 'created', type: 'integer', format: 'int64', example: 1633024800),
408+
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64', example: 1633024800),
409+
new OA\Property(property: 'active', type: 'boolean', example: true),
410+
new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'),
411+
new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'),
412+
new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Only for Stripe provider'),
413+
new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Only for Stripe provider'),
414+
new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Only for Stripe provider'),
415+
]
416+
)]
417+
class PaymentGatewayProfileSchema {}
418+
419+
#[OA\Schema(
420+
schema: 'PaginatedPaymentGatewayProfilesResponse',
421+
allOf: [
422+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
423+
new OA\Schema(
424+
properties: [
425+
new OA\Property(
426+
property: 'data',
427+
type: 'array',
428+
items: new OA\Items(ref: '#/components/schemas/PaymentGatewayProfile')
429+
)
430+
]
431+
)
432+
]
433+
)]
434+
class PaginatedPaymentGatewayProfilesResponseSchema {}
435+
436+
#[OA\Schema(
437+
schema: 'PaymentGatewayProfileCreateRequest',
438+
required: ['active', 'provider', 'application_type'],
439+
type: 'object',
440+
properties: [
441+
new OA\Property(property: 'active', type: 'boolean', example: true),
442+
new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'),
443+
new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'),
444+
new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Required for Stripe provider'),
445+
new OA\Property(property: 'live_secret_key', type: 'string', example: 'sk_live_...', description: 'Optional for Stripe provider'),
446+
new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Required with live_secret_key for Stripe'),
447+
new OA\Property(property: 'test_secret_key', type: 'string', example: 'sk_test_...', description: 'Optional for Stripe provider'),
448+
new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Required with test_secret_key for Stripe'),
449+
new OA\Property(property: 'send_email_receipt', type: 'boolean', example: true, description: 'Optional for Stripe provider'),
450+
new OA\Property(property: 'merchant_account_id', type: 'string', example: 'merchant_123', description: 'Optional for LawPay provider'),
451+
]
452+
)]
453+
class PaymentGatewayProfileCreateRequestSchema {}
454+
455+
#[OA\Schema(
456+
schema: 'PaymentGatewayProfileUpdateRequest',
457+
required: ['provider'],
458+
type: 'object',
459+
properties: [
460+
new OA\Property(property: 'active', type: 'boolean', example: true),
461+
new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'),
462+
new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'),
463+
new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Required for Stripe provider'),
464+
new OA\Property(property: 'live_secret_key', type: 'string', example: 'sk_live_...', description: 'Optional for Stripe provider'),
465+
new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Required with live_secret_key for Stripe'),
466+
new OA\Property(property: 'test_secret_key', type: 'string', example: 'sk_test_...', description: 'Optional for Stripe provider'),
467+
new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Required with test_secret_key for Stripe'),
468+
new OA\Property(property: 'send_email_receipt', type: 'boolean', example: true, description: 'Optional for Stripe provider'),
469+
new OA\Property(property: 'merchant_account_id', type: 'string', example: 'merchant_123', description: 'Optional for LawPay provider'),
470+
]
471+
)]
472+
class PaymentGatewayProfileUpdateRequestSchema {}

0 commit comments

Comments
 (0)