# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from ...types.page_identifier import PageIdentifier


class CheckCaptureResponse(UniversalBaseModel):
    """
    Response model for check capture processing.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unique ID for the check capture, to be used with the /api/MoneyIn/getpaid endpoint.
    """

    success: bool = pydantic.Field()
    """
    Indicates whether the check processing was successful.
    """

    process_date: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="processDate"),
        pydantic.Field(
            alias="processDate", description="The date and time when the check was processed (ISO 8601 format)."
        ),
    ]
    ocr_micr: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrMicr"),
        pydantic.Field(
            alias="ocrMicr",
            description="The OCR-extracted MICR (Magnetic Ink Character Recognition) line from the check.",
        ),
    ] = None
    ocr_micr_status: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrMicrStatus"),
        pydantic.Field(alias="ocrMicrStatus", description="Status of the MICR extraction process."),
    ] = None
    ocr_micr_confidence: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrMicrConfidence"),
        pydantic.Field(alias="ocrMicrConfidence", description="Confidence score for the MICR extraction (0 to 100)."),
    ] = None
    ocr_account_number: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrAccountNumber"),
        pydantic.Field(alias="ocrAccountNumber", description="The bank account number extracted from the check."),
    ] = None
    ocr_routing_number: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrRoutingNumber"),
        pydantic.Field(alias="ocrRoutingNumber", description="The bank routing number extracted from the check."),
    ] = None
    ocr_check_number: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrCheckNumber"),
        pydantic.Field(alias="ocrCheckNumber", description="The check number extracted from the check."),
    ] = None
    ocr_check_tran_code: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrCheckTranCode"),
        pydantic.Field(alias="ocrCheckTranCode", description="The transaction code extracted from the check."),
    ] = None
    ocr_amount: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrAmount"),
        pydantic.Field(alias="ocrAmount", description="The amount extracted via OCR from the check."),
    ] = None
    ocr_amount_status: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrAmountStatus"),
        pydantic.Field(alias="ocrAmountStatus", description="Status of the amount extraction process."),
    ] = None
    ocr_amount_confidence: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="ocrAmountConfidence"),
        pydantic.Field(
            alias="ocrAmountConfidence", description="Confidence score for the amount extraction (0 to 100)."
        ),
    ] = None
    amount_discrepancy_detected: typing_extensions.Annotated[
        bool,
        FieldMetadata(alias="amountDiscrepancyDetected"),
        pydantic.Field(
            alias="amountDiscrepancyDetected",
            description="Flag indicating whether there's a discrepancy between the provided amount and the OCR-detected amount.",
        ),
    ]
    endorsement_detected: typing_extensions.Annotated[
        bool,
        FieldMetadata(alias="endorsementDetected"),
        pydantic.Field(
            alias="endorsementDetected", description="Flag indicating whether an endorsement was detected on the check."
        ),
    ]
    errors: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    List of error messages that occurred during processing.
    """

    messages: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    List of informational messages about the processing.
    """

    car_lar_match_confidence: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="carLarMatchConfidence"),
        pydantic.Field(
            alias="carLarMatchConfidence",
            description="Confidence score for the match between Courtesy Amount Recognition (CAR) and Legal Amount Recognition (LAR).",
        ),
    ] = None
    car_lar_match_status: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="carLarMatchStatus"),
        pydantic.Field(alias="carLarMatchStatus", description="Status of the CAR/LAR match."),
    ] = None
    front_image: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="frontImage"),
        pydantic.Field(alias="frontImage", description="Processed front image of the check (Base64-encoded)."),
    ] = None
    rear_image: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="rearImage"),
        pydantic.Field(alias="rearImage", description="Processed rear image of the check (Base64-encoded)."),
    ] = None
    check_type: typing_extensions.Annotated[
        float,
        FieldMetadata(alias="checkType"),
        pydantic.Field(
            alias="checkType",
            description="Identifier for the type of check.\nPersonal = 1\nBusiness = 2\nOnly personal checks are supported for check capture.",
        ),
    ]
    reference_number: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="referenceNumber"),
        pydantic.Field(alias="referenceNumber", description="Reference number for the transaction."),
    ] = None
    page_identifier: typing_extensions.Annotated[
        typing.Optional[PageIdentifier], FieldMetadata(alias="pageIdentifier"), pydantic.Field(alias="pageIdentifier")
    ] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
