Medical Appointments API

MedicalCenterController extends BaseController
in package

Controller class for managing medical centers.

Tags
OA\Tag

( name="MedicalCenters", description="API Endpoints of Medical Centers" )

author

Luis Graciano contacto@luisgraciano.dev

Table of Contents

$path  : string
$routes  : array<string|int, mixed>
$path  : string
$routes  : array<string|int, mixed>
$medicalCenterService  : MedicalCenterService
__construct()  : mixed
MedicalCenterController constructor.
addApiRoutes()  : void
Create a RouteGroup for the controller and add the routes to it.
findAll()  : ResponseInterface
Get all medical centers.
findByPostalCode()  : ResponseInterface
Find medical centers by postal code.
checkParams()  : void
Check the given parameters against the given schema.
makeJsonResponse()  : ResponseInterface
Create a JSON response with the given result and status code.
addRoutes()  : void
Add routes to the given group.

Properties

$path

public string $path

The path of the controller (e.g. /appointment).

$routes

public array<string|int, mixed> $routes

The routes for the controller. The routes should be an array of arrays with the following keys: method, path, handler.

$routes

protected array<string|int, mixed> $routes = [['method' => 'GET', 'path' => '/find-all', 'handler' => 'findAll'], ['method' => 'GET', 'path' => '/find-by-postal-code/{postal_code}', 'handler' => 'findByPostalCode']]

The routes for the controller.

Methods

addApiRoutes()

Create a RouteGroup for the controller and add the routes to it.

public addApiRoutes(RouteCollectorProxy $group) : void
Parameters
$group : RouteCollectorProxy

The route group.

Tags
throws
Exception

If the controller does not have a path or routes property.

Return values
void

findAll()

Get all medical centers.

public findAll(ServerRequestInterface $request, ResponseInterface $response, array<string|int, mixed> $args) : ResponseInterface
Parameters
$request : ServerRequestInterface

The PSR-7 request.

$response : ResponseInterface

The PSR-7 response.

$args : array<string|int, mixed>

The route parameters (not used in this endpoint).

Tags
OA\Get

( path="/medical-center/find-all", tags={"MedicalCenters"}, summary="Get all medical centers", @OA\Response( response=200, description="Success", @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/MedicalCenter")) ), @OA\Response(response=500, ref="#/components/responses/500") )

throws
UnhandledException

If an unhandled exception occurs during processing.

Return values
ResponseInterface

The response with the list of medical centers.

findByPostalCode()

Find medical centers by postal code.

public findByPostalCode(ServerRequestInterface $request, ResponseInterface $response, array<string|int, mixed> $args) : ResponseInterface
Parameters
$request : ServerRequestInterface

The PSR-7 request.

$response : ResponseInterface

The PSR-7 response.

$args : array<string|int, mixed>

The route parameters with 'postal_code'.

Tags
OA\Get

( path="/medical-center/find-by-postal-code/{postal_code}", tags={"MedicalCenters"}, summary="Find medical centers by postal code", @OA\Parameter( name="postal_code", in="path", required=true, description="The postal code to search for medical centers", @OA\Schema(type="string") ), @OA\Response( response=200, description="Success", @OA\JsonContent(type="array", @OA\Items(ref="#/components/schemas/MedicalCenter")) ), @OA\Response(response=500, ref="#/components/responses/500"), @OA\Response(response=400, ref="#/components/responses/400") )

throws
UnhandledException

If an unhandled exception occurs during processing.

throws
BusinessValidationException

If there is a business validation exception.

Return values
ResponseInterface

The response with the list of medical centers.

checkParams()

Check the given parameters against the given schema.

protected checkParams(array<string|int, mixed> $params, array<string|int, mixed> $schema) : void
Parameters
$params : array<string|int, mixed>

The parameters to check.

$schema : array<string|int, mixed>

The schema to check against. The schema should be an array of arrays with the following keys: type, required, not_blank, min_number, max_number, min_length, max_length, regex, properties, items. The type can be one of the following: integer, string, boolean, object, array.

Tags
throws
BusinessValidationException

If a validation error occurs.

Return values
void

makeJsonResponse()

Create a JSON response with the given result and status code.

protected makeJsonResponse(ResponseInterface $response[, mixed $result = null ][, int $status_code = 200 ]) : ResponseInterface
Parameters
$response : ResponseInterface

The PSR-7 response.

$result : mixed = null

The data to be included in the JSON response.

$status_code : int = 200

The HTTP status code for the response (default is 200).

Return values
ResponseInterface

The PSR-7 response with JSON data and appropriate headers.

addRoutes()

Add routes to the given group.

private addRoutes(RouteCollectorProxy $newGroup) : void
Parameters
$newGroup : RouteCollectorProxy

The route group.

Tags
throws
Exception

If the controller does not have a routes property or if a route is missing a method, path, or handler.

Return values
void

Search results