# 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

from pydantic import BaseModel, field_validator


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

    id: str
    notes: str = ''
    absent: bool = False
    hourOut: str = ''
    hourIn: str = ''

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


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

    id: str
    name: str
    presence: List[PresenceItem]

    @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: str
    name: str
    selected: str


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

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