# generated by datamodel-codegen:
#   filename:  b.json
#   timestamp: 2024-10-29T04:06:30+00:00

from __future__ import annotations

import html
from typing import List, Optional

from pydantic import BaseModel, field_validator


class PresenceItem(BaseModel):
    model_config = {'extra': 'allow'}

    id: Optional[str] = None
    notes: Optional[str] = None
    absent: Optional[bool] = None
    hourOut: Optional[str] = None
    hourIn: Optional[str] = None

    @field_validator('hourOut', 'hourIn')
    def parse_hours(cls, value):
        if value == '--:--':
            return ''
        return value


class Child(BaseModel):
    model_config = {'extra': 'allow'}

    id: Optional[str] = None
    name: Optional[str] = None
    presence: Optional[List[PresenceItem]] = None

    @field_validator('name')
    def parse_name(cls, value):
        if isinstance(value, str):
            value = html.unescape(value)
        return value


class AbsentReason(BaseModel):
    model_config = {'extra': 'allow'}

    id: Optional[str] = None
    name: Optional[str] = None
    selected: Optional[str] = None


class SchoolQRCodeInfo(BaseModel):
    model_config = {'extra': 'allow'}

    translate: Optional[dict[str, str]] = None
    child: Optional[dict[str, Child]] = None
    absentReasons: Optional[List[AbsentReason]] = None
    numChild: Optional[int] = None
    schoolDate: Optional[str] = None
    schoolhour: Optional[str] = None
    hasPresence: Optional[bool] = None
    hasQrenable: Optional[bool] = None
    qrdate: Optional[str] = None
    schoolslug: Optional[str] = None
    schoolId: Optional[str] = None
    presencein: Optional[str] = None
    presenceout: Optional[str] = None
    presencesingleurl: Optional[str] = None
    presencesinglenoteurl: Optional[str] = None
    absenturl: Optional[str] = None
    presenceinurl: Optional[str] = None
    presenceouturl: Optional[str] = None
    multiplePresence: Optional[int] = None
    locale: Optional[str] = None
    language: Optional[str] = None
