"""Base models for the iMedNet SDK."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, Generic, List, Optional, TypeVar
from pydantic import Field
from imednet.models.json_base import JsonModel
[docs]class ImednetBaseModel(JsonModel):
"""
Core base model for all iMedNet API responses.
Design philosophy:
extra='ignore' silently drops new undocumented fields the API introduces.
populate_by_name allows models to be instantiated using either pythonic
snake_case names or original API camelCase names via Field aliases.
str_strip_whitespace trims leading and trailing whitespace from string values.
"""
[docs]class SortField(JsonModel):
"""Sorting information for a field in a paginated response."""
property: str = Field(..., description="Property to sort by")
direction: str = Field(..., description="Sort direction (ASC or DESC)")
[docs]class Error(JsonModel):
"""Error information in an API response."""
code: str = Field("", description="Error code")
message: str = Field("", description="Error message")
details: Dict[str, Any] = Field(default_factory=dict)
T = TypeVar("T")
[docs]class ApiResponse(JsonModel, Generic[T]):
"""Generic API response model."""
metadata: Metadata
pagination: Optional[Pagination] = None
data: T