# 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.batch_summary import BatchSummary
from .query_batches_response_records_item import QueryBatchesResponseRecordsItem


class QueryBatchesResponse(UniversalBaseModel):
    """
    Response body for queries about batches.

    Examples
    --------
    import datetime

    from payabli import BatchSummary, GeneralEvents
    from payabli.query_types import (
        QueryBatchesResponse,
        QueryBatchesResponseRecordsItem,
        QueryBatchesTransfer,
    )

    QueryBatchesResponse(
        summary=BatchSummary(
            page_size=20,
            total_amount=54049.71,
            total_net_amount=0.0,
            total_pages=3,
            total_records=3,
        ),
        records=[
            QueryBatchesResponseRecordsItem(
                id_batch=1049,
                batch_number="batch_2857_combined_08-26-2025_001",
                events_data=[
                    GeneralEvents(
                        description="Created",
                        event_time=datetime.datetime.fromisoformat(
                            "2025-08-25 07:19:27.619000+00:00",
                        ),
                        source="api",
                    )
                ],
                connector_name="GP",
                batch_date=datetime.datetime.fromisoformat(
                    "2025-08-25 20:00:00+00:00",
                ),
                batch_amount=0.0,
                batch_fees_amount=0.0,
                batch_auth_amount=0.0,
                batch_released_amount=0.0,
                batch_hold_amount=0.0,
                batch_returned_amount=0.0,
                batch_refund_amount=0.0,
                batch_split_amount=0.0,
                batch_status=2,
                batch_records=2,
                paypoint_id=187,
                paypoint_name="Gruzya Adventure Outfitters, LLC",
                paypoint_dba="Gruzya Adventure Outfitters",
                parent_org_name="Pilgrim Planner",
                parent_org_id=105,
                entry_name="47f4f8c7e1",
                batch_type=0,
                method="combined",
                expected_deposit_date=datetime.datetime.fromisoformat(
                    "2025-08-26 00:00:00+00:00",
                ),
                transfer_date=datetime.datetime.fromisoformat(
                    "2025-08-26 00:00:00+00:00",
                ),
            ),
            QueryBatchesResponseRecordsItem(
                id_batch=1043,
                batch_number="BT-2023041817-187",
                batch_date=datetime.datetime.fromisoformat(
                    "2023-04-18 17:01:03+00:00",
                ),
                batch_amount=219.02,
                batch_fees_amount=0.0,
                batch_auth_amount=0.0,
                batch_released_amount=0.0,
                batch_hold_amount=0.0,
                batch_returned_amount=0.0,
                batch_refund_amount=0.0,
                batch_split_amount=0.0,
                batch_status=2,
                batch_records=1,
                paypoint_id=187,
                paypoint_name="Gruzya Adventure Outfitters, LLC",
                paypoint_dba="Gruzya Adventure Outfitters",
                parent_org_name="Pilgrim Planner",
                parent_org_id=105,
                entry_name="d193cf9a46",
                batch_type=0,
                method="card",
                expected_deposit_date=datetime.datetime.fromisoformat(
                    "2023-04-19 00:00:00+00:00",
                ),
                transfer_date=datetime.datetime.fromisoformat(
                    "2025-09-02 00:00:00+00:00",
                ),
            ),
            QueryBatchesResponseRecordsItem(
                id_batch=1012,
                batch_number="BT-2023041421-187",
                transfer_identifier="ec310c3d-d4bf-4670-9524-00fcc4ab6a2a",
                events_data=[
                    GeneralEvents(
                        description="Created",
                        event_time=datetime.datetime.fromisoformat(
                            "2023-04-14 21:01:03+00:00",
                        ),
                        source="api",
                    ),
                    GeneralEvents(
                        description="Closed",
                        event_time=datetime.datetime.fromisoformat(
                            "2023-04-15 03:05:10+00:00",
                        ),
                        ref_data="batchId: 1012",
                        source="worker",
                    ),
                ],
                connector_name="GP",
                batch_date=datetime.datetime.fromisoformat(
                    "2023-04-14 21:01:03+00:00",
                ),
                batch_amount=1080.44,
                batch_fees_amount=0.0,
                batch_auth_amount=1080.44,
                batch_released_amount=0.0,
                batch_hold_amount=0.0,
                batch_returned_amount=0.0,
                batch_refund_amount=0.0,
                batch_split_amount=0.0,
                batch_status=2,
                batch_records=4,
                paypoint_id=187,
                paypoint_name="Gruzya Adventure Outfitters, LLC",
                paypoint_dba="Gruzya Adventure Outfitters",
                parent_org_name="Pilgrim Planner",
                parent_org_id=105,
                entry_name="d193cf9a46",
                batch_type=0,
                method="card",
                expected_deposit_date=datetime.datetime.fromisoformat(
                    "2023-04-15 00:00:00+00:00",
                ),
                transfer_date=datetime.datetime.fromisoformat(
                    "2025-09-02 00:00:00+00:00",
                ),
                transfer=QueryBatchesTransfer(
                    transfer_id=5998,
                    transfer_date=datetime.datetime.fromisoformat(
                        "2025-09-02 00:00:00+00:00",
                    ),
                    processor="gp",
                    transfer_status=1,
                    gross_amount=1080.44,
                    charge_back_amount=0.0,
                    returned_amount=0.0,
                    refund_amount=0.0,
                    hold_amount=0.0,
                    released_amount=0.0,
                    billing_fees_amount=0.0,
                    third_party_paid_amount=0.0,
                    adjustments_amount=0.0,
                    net_funded_amount=1080.44,
                ),
            ),
        ],
    )
    """

    records: typing_extensions.Annotated[typing.List[QueryBatchesResponseRecordsItem], FieldMetadata(alias="Records")]
    summary: typing_extensions.Annotated[BatchSummary, FieldMetadata(alias="Summary")]

    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
