- Added schemas, services, and routers for PROSEC, RCG2, Regulaciones, REIT, RequisitoPrevio, TLCS, and Vehiculos modules. - Each module includes search and get by ID functionalities. - Integrated FastAPI routers for each module into the main SITAR router. - Ensured proper response models using Pydantic for data validation.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Regulaciones Service"""
|
|
|
|
from typing import Optional, List
|
|
from ..common import SitarAPIBaseService
|
|
from .schemas import RegulacionesResponse
|
|
|
|
|
|
class RegulacionesService(SitarAPIBaseService):
|
|
"""Service for Regulaciones operations"""
|
|
|
|
_instance: Optional["RegulacionesService"] = None
|
|
|
|
@classmethod
|
|
def get_instance(cls) -> "RegulacionesService":
|
|
if cls._instance is None:
|
|
cls._instance = cls()
|
|
return cls._instance
|
|
|
|
async def search(
|
|
self,
|
|
fraccion: Optional[str] = None,
|
|
nico: Optional[str] = None,
|
|
skip: int = 0,
|
|
limit: int = 100,
|
|
) -> List[RegulacionesResponse]:
|
|
params = {"skip": skip, "limit": min(limit, 1000)}
|
|
if fraccion:
|
|
params["fraccion"] = fraccion
|
|
if nico:
|
|
params["nico"] = nico
|
|
|
|
data = await self._make_request("GET", "/api/v1/regulaciones/", params=params)
|
|
return [RegulacionesResponse(**item) for item in data]
|
|
|
|
async def get_by_id(self, sysid: int) -> RegulacionesResponse:
|
|
data = await self._make_request("GET", f"/api/v1/regulaciones/{sysid}")
|
|
return RegulacionesResponse(**data)
|