# 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()
    """
    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(
        default=None
    )
    """
    The OCR-extracted MICR (Magnetic Ink Character Recognition) line from the check.
    """

    ocr_micr_status: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrMicrStatus")] = (
        pydantic.Field(default=None)
    )
    """
    Status of the MICR extraction process.
    """

    ocr_micr_confidence: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrMicrConfidence")] = (
        pydantic.Field(default=None)
    )
    """
    Confidence score for the MICR extraction (0 to 100).
    """

    ocr_account_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrAccountNumber")] = (
        pydantic.Field(default=None)
    )
    """
    The bank account number extracted from the check.
    """

    ocr_routing_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrRoutingNumber")] = (
        pydantic.Field(default=None)
    )
    """
    The bank routing number extracted from the check.
    """

    ocr_check_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrCheckNumber")] = (
        pydantic.Field(default=None)
    )
    """
    The check number extracted from the check.
    """

    ocr_check_tran_code: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrCheckTranCode")] = (
        pydantic.Field(default=None)
    )
    """
    The transaction code extracted from the check.
    """

    ocr_amount: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrAmount")] = pydantic.Field(
        default=None
    )
    """
    The amount extracted via OCR from the check.
    """

    ocr_amount_status: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ocrAmountStatus")] = (
        pydantic.Field(default=None)
    )
    """
    Status of the amount extraction process.
    """

    ocr_amount_confidence: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="ocrAmountConfidence")
    ] = pydantic.Field(default=None)
    """
    Confidence score for the amount extraction (0 to 100).
    """

    amount_discrepancy_detected: typing_extensions.Annotated[bool, FieldMetadata(alias="amountDiscrepancyDetected")] = (
        pydantic.Field()
    )
    """
    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()
    )
    """
    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(default=None)
    """
    Confidence score for the match between Courtesy Amount Recognition (CAR) and Legal Amount Recognition (LAR).
    """

    car_lar_match_status: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="carLarMatchStatus")
    ] = pydantic.Field(default=None)
    """
    Status of the CAR/LAR match.
    """

    front_image: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="frontImage")] = pydantic.Field(
        default=None
    )
    """
    Processed front image of the check (Base64-encoded).
    """

    rear_image: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="rearImage")] = pydantic.Field(
        default=None
    )
    """
    Processed rear image of the check (Base64-encoded).
    """

    check_type: typing_extensions.Annotated[float, FieldMetadata(alias="checkType")] = pydantic.Field()
    """
    Identifier for the type of check.
    Personal = 1
    Business = 2
    Only personal checks are supported for check capture.
    """

    reference_number: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="referenceNumber")] = (
        pydantic.Field(default=None)
    )
    """
    Reference number for the transaction.
    """

    page_identifier: typing_extensions.Annotated[
        typing.Optional[PageIdentifier], FieldMetadata(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
