Add comprehensive project documentation for ClinicPro in CLAUDE.md and README.md
- Introduced CLAUDE.md for internal guidance on project structure, commands, and architecture. - Created README.md with detailed project overview, technology stack, directory structure, setup instructions, API endpoints, authentication flow, and external services.
This commit is contained in:
@@ -8,12 +8,14 @@ use App\Shared\Controller\BaseController;
|
||||
use App\Sms\Entity\SmsTemplate;
|
||||
use App\Sms\Repository\SmsTemplateRepository;
|
||||
use App\Sms\Service\SmsService;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
#[OA\Tag(name: 'SMS')]
|
||||
#[IsGranted('IS_AUTHENTICATED_FULLY')]
|
||||
class SmsController extends BaseController
|
||||
{
|
||||
@@ -24,6 +26,39 @@ class SmsController extends BaseController
|
||||
|
||||
// ── Send SMS directly ─────────────────────────────────────────────────────
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/sms/send',
|
||||
summary: 'Send an SMS message directly (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['mobile', 'message'],
|
||||
properties: [
|
||||
new OA\Property(property: 'mobile', type: 'string'),
|
||||
new OA\Property(property: 'message', type: 'string'),
|
||||
new OA\Property(property: 'provider', type: 'string', default: 'kavenegar'),
|
||||
]
|
||||
)
|
||||
),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'SMS queued for delivery',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', properties: [
|
||||
new OA\Property(property: 'message', type: 'string'),
|
||||
], type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 422, description: 'Validation error'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/send', methods: ['POST'])]
|
||||
public function send(Request $request): JsonResponse
|
||||
@@ -44,6 +79,37 @@ class SmsController extends BaseController
|
||||
|
||||
// ── Templates ─────────────────────────────────────────────────────────────
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/sms/template',
|
||||
summary: 'Create a new SMS template (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['name', 'body'],
|
||||
properties: [
|
||||
new OA\Property(property: 'name', type: 'string'),
|
||||
new OA\Property(property: 'body', type: 'string'),
|
||||
new OA\Property(property: 'variables', type: 'array', items: new OA\Items(type: 'string')),
|
||||
]
|
||||
)
|
||||
),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 201,
|
||||
description: 'Template created',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 422, description: 'Validation error'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/template', methods: ['POST'])]
|
||||
public function createTemplate(Request $request): JsonResponse
|
||||
@@ -63,6 +129,28 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $template->toArray()], 201);
|
||||
}
|
||||
|
||||
#[OA\Get(
|
||||
path: '/api/v1/sms/template/{uuid}',
|
||||
summary: 'Get an SMS template by UUID',
|
||||
security: [['bearerAuth' => []]],
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template details',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
]
|
||||
)]
|
||||
#[Route('/api/v1/sms/template/{uuid}', methods: ['GET'])]
|
||||
public function getTemplate(string $uuid): JsonResponse
|
||||
{
|
||||
@@ -73,6 +161,40 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $template->toArray()]);
|
||||
}
|
||||
|
||||
#[OA\Patch(
|
||||
path: '/api/v1/sms/template/{uuid}',
|
||||
summary: 'Update an SMS template (ROLE_ADMIN, only non-approved templates)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: false,
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'name', type: 'string'),
|
||||
new OA\Property(property: 'body', type: 'string'),
|
||||
new OA\Property(property: 'variables', type: 'array', items: new OA\Items(type: 'string')),
|
||||
]
|
||||
)
|
||||
),
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template updated',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
new OA\Response(response: 422, description: 'Template is already approved and cannot be edited'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/template/{uuid}', methods: ['PATCH'])]
|
||||
public function updateTemplate(string $uuid, Request $request): JsonResponse
|
||||
@@ -96,6 +218,29 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $template->toArray()]);
|
||||
}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/sms/template/{uuid}/submit',
|
||||
summary: 'Submit an SMS template for review (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template submitted for review',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/template/{uuid}/submit', methods: ['POST'])]
|
||||
public function submitTemplate(string $uuid): JsonResponse
|
||||
@@ -111,6 +256,31 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $template->toArray()]);
|
||||
}
|
||||
|
||||
#[OA\Delete(
|
||||
path: '/api/v1/sms/template/{uuid}',
|
||||
summary: 'Delete an SMS template (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template deleted',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', properties: [
|
||||
new OA\Property(property: 'message', type: 'string'),
|
||||
], type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/template/{uuid}', methods: ['DELETE'])]
|
||||
public function deleteTemplate(string $uuid): JsonResponse
|
||||
@@ -125,6 +295,25 @@ class SmsController extends BaseController
|
||||
|
||||
// ── Admin moderation ──────────────────────────────────────────────────────
|
||||
|
||||
#[OA\Get(
|
||||
path: '/api/v1/admin/sms/templates',
|
||||
summary: 'List all SMS templates (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'List of all SMS templates',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'array', items: new OA\Items(type: 'object')),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/admin/sms/templates', methods: ['GET'])]
|
||||
public function listTemplates(): JsonResponse
|
||||
@@ -133,6 +322,38 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $templates]);
|
||||
}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/admin/sms/template/{uuid}/approve',
|
||||
summary: 'Approve an SMS template (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: false,
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'note', type: 'string', nullable: true),
|
||||
new OA\Property(property: 'provider_code', type: 'string', nullable: true),
|
||||
]
|
||||
)
|
||||
),
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template approved',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/admin/sms/template/{uuid}/approve', methods: ['POST'])]
|
||||
public function approveTemplate(string $uuid, Request $request): JsonResponse
|
||||
@@ -150,6 +371,39 @@ class SmsController extends BaseController
|
||||
return $this->success(['data' => $template->toArray()]);
|
||||
}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/admin/sms/template/{uuid}/reject',
|
||||
summary: 'Reject an SMS template (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['note'],
|
||||
properties: [
|
||||
new OA\Property(property: 'note', type: 'string', description: 'Rejection reason (required)'),
|
||||
]
|
||||
)
|
||||
),
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Template rejected',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Not found'),
|
||||
new OA\Response(response: 422, description: 'Rejection note is required'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/admin/sms/template/{uuid}/reject', methods: ['POST'])]
|
||||
public function rejectTemplate(string $uuid, Request $request): JsonResponse
|
||||
@@ -172,6 +426,41 @@ class SmsController extends BaseController
|
||||
|
||||
// ── Send via template ─────────────────────────────────────────────────────
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/v1/sms/send-template',
|
||||
summary: 'Send an SMS using an approved template (ROLE_ADMIN)',
|
||||
security: [['bearerAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['mobile', 'template_uuid'],
|
||||
properties: [
|
||||
new OA\Property(property: 'mobile', type: 'string'),
|
||||
new OA\Property(property: 'template_uuid', type: 'string'),
|
||||
new OA\Property(property: 'vars', type: 'object', description: 'Key-value map of template variables'),
|
||||
new OA\Property(property: 'provider', type: 'string', default: 'kavenegar'),
|
||||
]
|
||||
)
|
||||
),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'SMS queued via template',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'success', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'data', properties: [
|
||||
new OA\Property(property: 'message', type: 'string'),
|
||||
], type: 'object'),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthorized'),
|
||||
new OA\Response(response: 403, description: 'Forbidden – ROLE_ADMIN required'),
|
||||
new OA\Response(response: 404, description: 'Template not found'),
|
||||
new OA\Response(response: 422, description: 'Template not yet approved'),
|
||||
]
|
||||
)]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
#[Route('/api/v1/sms/send-template', methods: ['POST'])]
|
||||
public function sendViaTemplate(Request $request): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user