Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Histologe] Améliorations route GET + Documentation #3524

Merged
merged 16 commits into from
Jan 24, 2025
102 changes: 0 additions & 102 deletions src/Controller/Api/ResourceController.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Controller/Api/SignalementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getSignalementList(
// preload some data to reduce the number of queries
$desordreCritereRepository->findAll();
$desordreCategoriesRepository->findAll();
// main query

/** @var User $user */
$user = $this->getUser();
$signalements = $signalementRepository->findForAPI(user: $user, limit: $limit, page: $page);
Expand Down
16 changes: 8 additions & 8 deletions src/Controller/Security/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class SecurityController extends AbstractController
#[Security(name: null)]
#[OA\Post(
path: '/api/login',
summary: 'Login using email and password',
summary: 'Se connecter en utilisant l\'email et le mot de passe',
security: null,
requestBody: new OA\RequestBody(
description: 'Credentials for logging in',
description: 'Identifiants pour se connecter',
required: true,
content: new OA\JsonContent(
required: ['email', 'password'],
Expand All @@ -46,7 +46,7 @@ class SecurityController extends AbstractController
responses: [
new OA\Response(
response: 200,
description: 'Successful login',
description: 'Connexion réussie',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'token', type: 'string', example: 'abcd1234'),
Expand All @@ -57,11 +57,11 @@ class SecurityController extends AbstractController
),
new OA\Response(
response: 401,
description: 'Invalid credentials',
description: 'Identifiants invalides',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'error', type: 'string', example: 'Invalid credentials.'),
sfinx13 marked this conversation as resolved.
Show resolved Hide resolved
new OA\Property(property: 'message', type: 'string', example: 'The credentials are invalid.'),
new OA\Property(property: 'error', type: 'string', example: 'Identifiants invalides.'),
new OA\Property(property: 'message', type: 'string', example: 'Les identifiants sont invalides.'),
],
type: 'object'
)
Expand All @@ -73,8 +73,8 @@ public function loginApi(
): JsonResponse {
if (!$user) {
return $this->json([
'error' => 'Invalid credentials.',
'message' => 'The credentials are invalid.',
'error' => 'Identifiants invalides.',
'message' => 'Les identifiants sont invalides.',
], Response::HTTP_UNAUTHORIZED);
}

Expand Down
82 changes: 82 additions & 0 deletions src/Dto/Api/Model/Adresse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace App\Dto\Api\Model;

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'Adresse',
description: 'Représentation d\'une adresse complète. <br>
L\'adresse du signalement correspond au logement concerné par le signalement (celle de l\'occupant).',
)]
class Adresse
{
public function __construct(
#[OA\Property(
description: 'Ligne principale de l\'adresse',
example: '123 Rue de Paris'
)]
public ?string $adresse = null,
#[OA\Property(
description: 'Code postal',
example: '75000'
)]
public ?string $codePostal = null,
#[OA\Property(
description: 'Ville',
example: 'Paris'
)]
public ?string $ville = null,
#[OA\Property(
description: 'Numéro d\'étage',
example: '3'
)]
public ?string $etage = null,
#[OA\Property(
description: 'Escalier spécifié',
example: 'B'
)]
public ?string $escalier = null,
#[OA\Property(
description: 'Numéro d\'appartement',
example: '34A'
)]
public ?string $numAppart = null,
#[OA\Property(
description: 'Code INSEE de la ville',
example: '75101'
)]
public ?string $codeInsee = null,
#[OA\Property(
description: 'Latitude géographique',
type: 'number',
format: 'float',
example: 48.8566
)]
public ?float $latitude = null,
#[OA\Property(
description: 'Longitude géographique',
type: 'number',
format: 'float',
example: 2.3522
)]
public ?float $longitude = null,
#[OA\Property(
description: 'Autre adresse (si applicable)',
type: 'string',
example: '45B Rue des Lilas'
)]
public ?string $adresseAutre = null,
#[OA\Property(
description: 'Identifiant RNB',
example: 'RNB123456'
)]
public ?string $rnbId = null,
#[OA\Property(
description: 'Clé BAN de l\'adresse',
example: '763f8c4b'
)]
public ?string $cleBanAdresse = null,
) {
}
}
24 changes: 24 additions & 0 deletions src/Dto/Api/Model/Desordre.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@

use App\Entity\Criticite;
use App\Entity\DesordrePrecision;
use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'Desordre',
description: 'Schéma représentant les désordres identifiés dans le logement.'
)]
class Desordre
{
#[OA\Property(
description: 'Catégorie du désordre.',
example: 'Eau potable / assainissement'
)]
public string $categorie;
#[OA\Property(
description: 'Zone exacte du logement ou du bâtiment où le désordre est constaté.',
enum: ['BATIMENT', 'LOGEMENT'],
Copy link
Collaborator Author

@sfinx13 sfinx13 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici le type enum n'existe pas donc utilisations de la fonctionnalité enum d'openapi pour proposer les valeurs possibles à travers la doc

example: 'LOGEMENT',
nullable: true
)]
public ?string $zone;
#[OA\Property(
description: 'Liste des observations détaillées associées au désordre.',
example: [
"Il n'y a pas d'eau potable dans le logement",
"L'évacuation des eaux ne marche pas (mauvaises odeurs, pas d'évacuation, fuites...)",
"Il n'y a pas d'eau chaude dans le logement",
],
nullable: true
)]
public array $details = [];

public function __construct(
Expand Down
6 changes: 6 additions & 0 deletions src/Dto/Api/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace App\Dto\Api\Model;

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'File',
description: 'Représentation d\'un fichier.'
sfinx13 marked this conversation as resolved.
Show resolved Hide resolved
)]
class File
{
public string $titre;
Expand Down
10 changes: 0 additions & 10 deletions src/Dto/Api/Model/Geolocalisation.php

This file was deleted.

66 changes: 64 additions & 2 deletions src/Dto/Api/Model/Intervention.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,86 @@

namespace App\Dto\Api\Model;

use App\Entity\Enum\InterventionType;
use App\Entity\Intervention as InterventionEntity;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'Intervention',
description: 'Représentation d\'une intervention.'
)]
class Intervention
{
#[OA\Property(
description: 'Date de l\'intervention.',
type: 'string',
format: 'date-time',
example: '2024-11-03T14:30:00+00:00',
nullable: true
)]
public string $dateIntervention;
public ?string $type;

#[OA\Property(
description: 'Type d\'intervention réalisée.',
sfinx13 marked this conversation as resolved.
Show resolved Hide resolved
example: 'VISITE',
nullable: true
)]
public ?InterventionType $type;
#[OA\Property(
description: 'Statut de l\'intervention.',
sfinx13 marked this conversation as resolved.
Show resolved Hide resolved
type: 'string',
enum: ['PLANNED', 'DONE', 'NOT_DONE', 'CANCELED'],
example: 'DONE',
nullable: true
)]
public ?string $statut;

#[OA\Property(
ref: new Model(type: Partner::class),
description: 'Partenaire ayant effectué l\'intervention.',
type: 'object',
nullable: true
)]
public ?Partner $partner;

#[OA\Property(
description: 'Détails additionnels relatifs à l\'intervention.',
type: 'string',
example: 'Travaux à prévoir.',
nullable: true
)]
public ?string $details;

#[OA\Property(
description: 'Conclusions ou observations spécifiques liées à l\'intervention.',
type: 'array',
items: new OA\Items(type: 'string'),
example: []
)]
public array $conclusions = [];

#[OA\Property(
description: 'Indique si l\'occupant était présent lors de l\'intervention.',
type: 'boolean',
example: true,
nullable: true
)]
public ?bool $occupantPresent;

#[OA\Property(
description: 'Indique si le propriétaire était présent lors de l\'intervention.',
type: 'boolean',
example: false,
nullable: true
)]
public ?bool $proprietairePresent;

public function __construct(
InterventionEntity $intervention,
) {
$this->dateIntervention = $intervention->getScheduledAt()->format(\DATE_ATOM);
$this->type = $intervention->getType()?->label();
$this->type = $intervention->getType();
$this->statut = $intervention->getStatus();
$this->partner = $intervention->getPartner() ? new Partner($intervention->getPartner()) : null;
$this->details = $intervention->getDetails(); // traitement de suppression du html
Expand Down
Loading
Loading