# generated by datamodel-codegen:
#   filename:  ffiec_rest_api_openapi.yaml
#   timestamp: 2025-09-03T15:53:23+00:00

from __future__ import annotations

from typing import List

from pydantic import BaseModel, Field, RootModel


class Error(BaseModel):
    Message: str | None = Field(None, description="Error message")
    Code: int | None = None


class ReportingPeriod(RootModel[str]):
    root: str = Field(
        ...,
        description="Reporting period in MM/DD/YYYY format",
        examples=["12/31/2023"],
        pattern="^\\d{1,2}/\\d{1,2}/\\d{4}$",
    )


class Institution(BaseModel):
    ID_RSSD: int = Field(
        ...,
        description="RSSD identifier (normalized to string by DataNormalizer)",
        examples=[480228],
    )
    FDICCertNumber: int | None = Field(
        None,
        description="FDIC certificate number (normalized to string by DataNormalizer)",
        examples=[26539],
    )
    OCCChartNumber: int | None = Field(
        None, description="OCC charter number (0 if not applicable)", examples=[0]
    )
    OTSDockNumber: int | None = Field(
        None, description="OTS docket number (0 if not applicable)", examples=[0]
    )
    PrimaryABARoutNumber: int | None = Field(
        None,
        description="ABA routing number (0 if not applicable)",
        examples=[65103243],
    )
    Name: str = Field(
        ...,
        description="Institution name (may be padded with spaces)",
        examples=[
            "CITIZENS' BANK, INC.                                                                                                    "
        ],
    )
    State: str | None = Field(
        None, description='State code or "0" for international', examples=["AL"]
    )
    City: str | None = Field(
        None,
        description="City name (may be padded with spaces)",
        examples=["ROBERTSDALE              "],
    )
    Address: str | None = Field(
        None,
        description="Street address (may be padded with spaces)",
        examples=["21980 PALMER STREET                     "],
    )
    ZIP: int | None = Field(
        None,
        description="ZIP code (normalized to string by DataNormalizer to preserve leading zeros)",
        examples=[36567],
    )
    FilingType: str | None = Field(
        None, description="Filing type code", examples=["051"]
    )
    HasFiledForReportingPeriod: bool | None = Field(
        None,
        description="Whether institution filed for the reporting period",
        examples=[True],
    )


class SubmissionInfo(BaseModel):
    ID_RSSD: str = Field(
        ...,
        description="RSSD identifier (normalized to string by DataNormalizer)",
        examples=["3358270"],
    )
    DateTime: str = Field(
        ...,
        description="Submission timestamp in M/D/YYYY H:MM:SS AM/PM format",
        examples=["2/20/2024 3:23:30 PM"],
        pattern="^\\d{1,2}/\\d{1,2}/\\d{4} \\d{1,2}:\\d{2}:\\d{2} (AM|PM)$",
    )


class ReportingPeriodsResponse(RootModel[List[ReportingPeriod]]):
    root: List[ReportingPeriod] = Field(
        ...,
        description="Array of reporting periods in chronological order (newest first)",
        examples=[["6/30/2025", "3/31/2025", "12/31/2024"]],
    )


class UBPRReportingPeriodsResponseItem(RootModel[str]):
    root: str = Field(..., pattern="^\\d{1,2}/\\d{1,2}/\\d{4}$")


class UBPRReportingPeriodsResponse(RootModel[List[UBPRReportingPeriodsResponseItem]]):
    root: List[UBPRReportingPeriodsResponseItem] = Field(
        ...,
        description="Array of UBPR reporting periods - same format as Call periods",
        examples=[["12/31/2002", "3/31/2003", "6/30/2003"]],
    )


class InstitutionsResponse(RootModel[List[Institution]]):
    root: List[Institution] = Field(
        ..., description="Array of institutions that filed for the reporting period"
    )


class RSSDIDsResponse(RootModel[List[str]]):
    root: List[str] = Field(
        ...,
        description="Array of RSSD IDs from RetrieveFilersSinceDate (normalized to strings by DataNormalizer)",
        examples=[["3358270", "2132941", "1447639"]],
    )


class SubmissionsResponse(RootModel[List[SubmissionInfo]]):
    root: List[SubmissionInfo] = Field(
        ..., description="Array of submission information records"
    )


class XBRLData(RootModel[bytes]):
    root: bytes = Field(..., description="XBRL data file (XML format)")


class PDFData(RootModel[bytes]):
    root: bytes = Field(..., description="PDF data file")


class SDFData(RootModel[bytes]):
    root: bytes = Field(
        ..., description="SDF (Standard Data Format) text file - tab-delimited format"
    )
