Implement Routes for Clients #173

Closed
opened 2025-12-12 17:15:33 +00:00 by GFMpt13 · 0 comments
GFMpt13 commented 2025-12-12 17:15:33 +00:00 (Migrated from github.com)

Implement the REST endpoints for the Client entity, connecting the API layer to the existing ClientRepo.

The router must handle standard CRUD operations and specific lookups (by NIF/Email). Crucially, it must map the custom exceptions raised by the repository (e.g., DuplicateClientNIFError) to appropriate HTTP Status Codes.

Technical Requirements:

  • File: src/routers/clients.py
  • Prefix: /clients
  • Tags: ["Clients"]
  • Dependency: Inject ClientRepo using Depends().
  • Testing: Use AsyncMock to mock the repository layer. Do not connect to the real database.

Exception Mapping Strategy:

  • ClientNotFoundError -> 404 Not Found
  • DuplicateClientNIFError -> 409 Conflict
  • DuplicateClientEmailError -> 409 Conflict
  • ClientDatabaseError -> 500 Internal Server Error

TDD Checklist:

Implement the REST endpoints for the Client entity, connecting the API layer to the existing ClientRepo. The router must handle standard CRUD operations and specific lookups (by NIF/Email). Crucially, it must map the custom exceptions raised by the repository (e.g., DuplicateClientNIFError) to appropriate HTTP Status Codes. Technical Requirements: - File: src/routers/clients.py - Prefix: /clients - Tags: ["Clients"] - Dependency: Inject ClientRepo using Depends(). - Testing: Use AsyncMock to mock the repository layer. Do not connect to the real database. Exception Mapping Strategy: - ClientNotFoundError -> 404 Not Found - DuplicateClientNIFError -> 409 Conflict - DuplicateClientEmailError -> 409 Conflict - ClientDatabaseError -> 500 Internal Server Error TDD Checklist: - [x] #174 - [x] #175 - [x] #176
Sign in to join this conversation.
No description provided.