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

import datetime as dt
import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from ...types.ach_holder_type import AchHolderType
from ...types.ach_sec_code import AchSecCode
from ...types.batch_number import BatchNumber
from ...types.bill_data import BillData
from ...types.category import Category
from ...types.chargeback_id import ChargebackId
from ...types.created_at import CreatedAt
from ...types.dbaname import Dbaname
from ...types.deposit_date import DepositDate
from ...types.device import Device
from ...types.entrypage_id import EntrypageId
from ...types.entrypointfield import Entrypointfield
from ...types.expected_deposit_date import ExpectedDepositDate
from ...types.external_paypoint_id import ExternalPaypointId
from ...types.fee_amount import FeeAmount
from ...types.legalname import Legalname
from ...types.maskedaccount import Maskedaccount
from ...types.netamountnullable import Netamountnullable
from ...types.operation import Operation
from ...types.order_id import OrderId
from ...types.org_parent_name import OrgParentName
from ...types.orgid import Orgid
from ...types.payor_id import PayorId
from ...types.paypoint_id import PaypointId
from ...types.pending_fee_amount import PendingFeeAmount
from ...types.query_c_fee_transaction import QueryCFeeTransaction
from ...types.query_payment_data import QueryPaymentData
from ...types.query_response_data import QueryResponseData
from ...types.query_transaction_events import QueryTransactionEvents
from ...types.query_transaction_payor_data import QueryTransactionPayorData
from ...types.refund_id import RefundId
from ...types.retrieval_id import RetrievalId
from ...types.returned_id import ReturnedId
from ...types.source import Source
from ...types.split_funding import SplitFunding
from ...types.transaction_time import TransactionTime


class BatchDetailResponseRecord(UniversalBaseModel):
    """
    Examples
    --------
    import datetime

    from payabli import (
        PaymentCategories,
        PaymentDetail,
        QueryPaymentData,
        QueryResponseData,
        QueryTransactionEvents,
        QueryTransactionPayorData,
        SplitFundingContent,
    )
    from payabli.query_types import BatchDetailResponseRecord

    BatchDetailResponseRecord(
        id=25048,
        method="ach",
        settled_amount=0.5,
        type="credit",
        batch_number="batch-100-20-2024",
        batch_amount=32.0,
        payment_trans_id="245-9e4072eef77e45979ea0e49f680000X",
        payment_trans_status=1,
        schedule_reference=0,
        gateway_trans_id="TRN_XXXXX",
        order_id="",
        trans_method="ach",
        payment_data=QueryPaymentData(
            account_type="Checking",
            holder_name="Lydia Marshall",
            masked_account="1XXXXXX5678",
            payment_details=PaymentDetail(
                categories=[
                    PaymentCategories(
                        amount=1000.0,
                        label="Deposit",
                    )
                ],
                currency="USD",
                service_fee=0.0,
                split_funding=[SplitFundingContent()],
                total_amount=2.0,
            ),
        ),
        net_amount=2.0,
        operation="Sale",
        category="auth",
        source="api",
        status=1,
        transaction_time=datetime.datetime.fromisoformat(
            "2024-11-19 15:58:01+00:00",
        ),
        customer=QueryTransactionPayorData(
            billing_address_1="100 Golden Ridge Drive",
            billing_address_2="STE 100",
            billing_city="Mendota",
            billing_country="US",
            billing_email="lydia@example.com",
            billing_phone="+12345678",
            billing_state="VA",
            billing_zip="20147",
            customer_id=2707,
            customer_number="901102",
            customer_status=1,
            first_name="Lydia",
            last_name="Marshall",
        ),
        settlement_date=datetime.datetime.fromisoformat(
            "2024-11-20 00:00:00+00:00",
        ),
        payment_settlement_status=1,
        batch_status=1,
        deposit_date=datetime.datetime.fromisoformat(
            "2024-11-22 00:00:00+00:00",
        ),
        expected_deposit_date=datetime.datetime.fromisoformat(
            "2024-11-22 00:00:00+00:00",
        ),
        masked_account="1XXXXXX5678",
        created_at=datetime.datetime.fromisoformat(
            "2024-11-19 15:58:01+00:00",
        ),
        paypoint_legalname="Gruzya Adventure Outfitters, LLC",
        response_data=QueryResponseData(
            authcode=" ",
            avsresponse=" ",
            avsresponse_text="",
            cvvresponse=" ",
            cvvresponse_text=" ",
            emv_auth_response_data=" ",
            response="Success",
            response_code="100",
            response_code_text="Transaction was approved.",
            responsetext="CAPTURED",
            result_code="A0000",
            result_code_text="Approved",
            transactionid="TRN_xwCAjQorWAYX1nAhAoHZVfN8iYHbI0",
        ),
        paypoint_dbaname="Gruzya Adventure Outfitters, LLC",
        parent_org_name="Pilgrim Planner",
        parent_org_id=123,
        paypoint_entryname="7f1a3816XX",
        device_id="",
        retrieval_id=0,
        chargeback_id=0,
        ach_holder_type="personal",
        ach_sec_code="PPD",
        connector_name="DefaultConnector",
        entrypage_id=0,
        fee_amount=0.0,
        org_id=123,
        payor_id=2707,
        paypoint_id=123,
        pending_fee_amount=0.0,
        refund_id=0,
        returned_id=0,
        split_funding_instructions=[],
        total_amount=2.0,
        cfee_transactions=[],
        transaction_events=[
            QueryTransactionEvents(
                event_time=datetime.datetime.fromisoformat(
                    "2024-11-19 15:57:40+00:00",
                ),
                trans_event="Created",
            ),
            QueryTransactionEvents(
                event_data={
                    "account_id": "TRA_XXXXX",
                    "account_name": "123456",
                    "action": {
                        "app_id": "XXXXX",
                        "app_name": "PayAbli",
                        "id": "ACT_XXXXX",
                        "result_code": "SUCCESS",
                        "time_created": "2024-11-19T20:58:01.583Z",
                        "type": "AUTHORIZE",
                    },
                    "amount": "200",
                    "batch_id": "",
                    "capture_mode": "AUTO",
                    "channel": "CNP",
                    "country": "US",
                    "currency": "USD",
                    "fees": {"amount": "0", "rate": "0.00", "total_amount": "0"},
                    "id": "TRN_XXXXX",
                    "merchant_amount": "200",
                    "merchant_id": "MER_XXXXX",
                    "merchant_name": "Henriette97",
                    "order": {"reference": ""},
                    "payment_method": {
                        "bank_transfer": {
                            "account_type": "CHECKING",
                            "bank": {"name": ""},
                            "masked_account_number_last4": "XXXX5678",
                        },
                        "entry_mode": "ECOM",
                        "message": "Success",
                        "narrative": "Lydia Marshall",
                        "result": "00",
                    },
                    "reference": "245-XXXXX",
                    "status": "CAPTURED",
                    "time_created": "2024-11-19T20:58:01.583Z",
                    "type": "SALE",
                },
                event_time=datetime.datetime.fromisoformat(
                    "2024-11-19 20:58:01+00:00",
                ),
                trans_event="Approved",
            ),
            QueryTransactionEvents(
                event_time=datetime.datetime.fromisoformat(
                    "2024-11-20 03:05:10+00:00",
                ),
                trans_event="ClosedBatch",
            ),
        ],
        external_paypoint_id="ext-paypoint-123",
        is_hold=0,
    )
    """

    id: typing_extensions.Annotated[int, FieldMetadata(alias="Id"), pydantic.Field(alias="Id")]
    method: typing_extensions.Annotated[str, FieldMetadata(alias="Method"), pydantic.Field(alias="Method")]
    wallet_type: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="WalletType"), pydantic.Field(alias="WalletType")
    ] = None
    settled_amount: typing_extensions.Annotated[
        float, FieldMetadata(alias="SettledAmount"), pydantic.Field(alias="SettledAmount")
    ]
    type: typing_extensions.Annotated[str, FieldMetadata(alias="Type"), pydantic.Field(alias="Type")]
    batch_number: typing_extensions.Annotated[
        BatchNumber, FieldMetadata(alias="BatchNumber"), pydantic.Field(alias="BatchNumber")
    ]
    batch_amount: typing_extensions.Annotated[
        float, FieldMetadata(alias="BatchAmount"), pydantic.Field(alias="BatchAmount")
    ]
    payment_trans_id: typing_extensions.Annotated[
        str, FieldMetadata(alias="PaymentTransId"), pydantic.Field(alias="PaymentTransId")
    ]
    payment_trans_status: typing_extensions.Annotated[
        int, FieldMetadata(alias="PaymentTransStatus"), pydantic.Field(alias="PaymentTransStatus")
    ]
    schedule_reference: typing_extensions.Annotated[
        int, FieldMetadata(alias="ScheduleReference"), pydantic.Field(alias="ScheduleReference")
    ]
    gateway_trans_id: typing_extensions.Annotated[
        str, FieldMetadata(alias="GatewayTransId"), pydantic.Field(alias="GatewayTransId")
    ]
    order_id: typing_extensions.Annotated[OrderId, FieldMetadata(alias="OrderId"), pydantic.Field(alias="OrderId")]
    trans_method: typing_extensions.Annotated[
        str, FieldMetadata(alias="TransMethod"), pydantic.Field(alias="TransMethod")
    ]
    payment_data: typing_extensions.Annotated[
        typing.Optional[QueryPaymentData], FieldMetadata(alias="PaymentData"), pydantic.Field(alias="PaymentData")
    ] = None
    net_amount: typing_extensions.Annotated[
        Netamountnullable, FieldMetadata(alias="NetAmount"), pydantic.Field(alias="NetAmount")
    ]
    operation: typing_extensions.Annotated[
        Operation, FieldMetadata(alias="Operation"), pydantic.Field(alias="Operation")
    ]
    category: typing_extensions.Annotated[Category, FieldMetadata(alias="Category"), pydantic.Field(alias="Category")]
    source: typing_extensions.Annotated[
        typing.Optional[Source], FieldMetadata(alias="Source"), pydantic.Field(alias="Source")
    ] = None
    status: typing_extensions.Annotated[int, FieldMetadata(alias="Status"), pydantic.Field(alias="Status")]
    transaction_time: typing_extensions.Annotated[
        TransactionTime, FieldMetadata(alias="TransactionTime"), pydantic.Field(alias="TransactionTime")
    ]
    customer: typing_extensions.Annotated[
        typing.Optional[QueryTransactionPayorData], FieldMetadata(alias="Customer"), pydantic.Field(alias="Customer")
    ] = None
    settlement_date: typing_extensions.Annotated[
        dt.datetime, FieldMetadata(alias="SettlementDate"), pydantic.Field(alias="SettlementDate")
    ]
    payment_settlement_status: typing_extensions.Annotated[
        int, FieldMetadata(alias="PaymentSettlementStatus"), pydantic.Field(alias="PaymentSettlementStatus")
    ]
    batch_status: typing_extensions.Annotated[
        int, FieldMetadata(alias="BatchStatus"), pydantic.Field(alias="BatchStatus")
    ]
    deposit_date: typing_extensions.Annotated[
        DepositDate, FieldMetadata(alias="DepositDate"), pydantic.Field(alias="DepositDate")
    ]
    expected_deposit_date: typing_extensions.Annotated[
        ExpectedDepositDate, FieldMetadata(alias="ExpectedDepositDate"), pydantic.Field(alias="ExpectedDepositDate")
    ]
    masked_account: typing_extensions.Annotated[
        Maskedaccount, FieldMetadata(alias="MaskedAccount"), pydantic.Field(alias="MaskedAccount")
    ]
    created_at: typing_extensions.Annotated[
        CreatedAt, FieldMetadata(alias="CreatedAt"), pydantic.Field(alias="CreatedAt")
    ]
    paypoint_legalname: typing_extensions.Annotated[
        Legalname, FieldMetadata(alias="PaypointLegalname"), pydantic.Field(alias="PaypointLegalname")
    ]
    response_data: typing_extensions.Annotated[
        typing.Optional[QueryResponseData], FieldMetadata(alias="ResponseData"), pydantic.Field(alias="ResponseData")
    ] = None
    paypoint_dbaname: typing_extensions.Annotated[
        Dbaname, FieldMetadata(alias="PaypointDbaname"), pydantic.Field(alias="PaypointDbaname")
    ]
    parent_org_name: typing_extensions.Annotated[
        OrgParentName, FieldMetadata(alias="ParentOrgName"), pydantic.Field(alias="ParentOrgName")
    ]
    parent_org_id: typing_extensions.Annotated[
        int, FieldMetadata(alias="ParentOrgId"), pydantic.Field(alias="ParentOrgId")
    ]
    paypoint_entryname: typing_extensions.Annotated[
        Entrypointfield, FieldMetadata(alias="PaypointEntryname"), pydantic.Field(alias="PaypointEntryname")
    ]
    device_id: typing_extensions.Annotated[
        typing.Optional[Device], FieldMetadata(alias="DeviceId"), pydantic.Field(alias="DeviceId")
    ] = None
    retrieval_id: typing_extensions.Annotated[
        RetrievalId, FieldMetadata(alias="RetrievalId"), pydantic.Field(alias="RetrievalId")
    ]
    chargeback_id: typing_extensions.Annotated[
        ChargebackId, FieldMetadata(alias="ChargebackId"), pydantic.Field(alias="ChargebackId")
    ]
    ach_holder_type: typing_extensions.Annotated[
        AchHolderType, FieldMetadata(alias="AchHolderType"), pydantic.Field(alias="AchHolderType")
    ]
    ach_sec_code: typing_extensions.Annotated[
        AchSecCode, FieldMetadata(alias="AchSecCode"), pydantic.Field(alias="AchSecCode")
    ]
    connector_name: typing_extensions.Annotated[
        str, FieldMetadata(alias="ConnectorName"), pydantic.Field(alias="ConnectorName")
    ]
    entrypage_id: typing_extensions.Annotated[
        EntrypageId, FieldMetadata(alias="EntrypageId"), pydantic.Field(alias="EntrypageId")
    ]
    fee_amount: typing_extensions.Annotated[
        FeeAmount, FieldMetadata(alias="FeeAmount"), pydantic.Field(alias="FeeAmount")
    ]
    org_id: typing_extensions.Annotated[Orgid, FieldMetadata(alias="OrgId"), pydantic.Field(alias="OrgId")]
    payor_id: typing_extensions.Annotated[PayorId, FieldMetadata(alias="PayorId"), pydantic.Field(alias="PayorId")]
    paypoint_id: typing_extensions.Annotated[
        PaypointId, FieldMetadata(alias="PaypointId"), pydantic.Field(alias="PaypointId")
    ]
    pending_fee_amount: typing_extensions.Annotated[
        PendingFeeAmount, FieldMetadata(alias="PendingFeeAmount"), pydantic.Field(alias="PendingFeeAmount")
    ]
    refund_id: typing_extensions.Annotated[RefundId, FieldMetadata(alias="RefundId"), pydantic.Field(alias="RefundId")]
    returned_id: typing_extensions.Annotated[
        ReturnedId, FieldMetadata(alias="ReturnedId"), pydantic.Field(alias="ReturnedId")
    ]
    split_funding_instructions: typing_extensions.Annotated[
        SplitFunding, FieldMetadata(alias="splitFundingInstructions"), pydantic.Field(alias="splitFundingInstructions")
    ]
    total_amount: typing_extensions.Annotated[
        float, FieldMetadata(alias="TotalAmount"), pydantic.Field(alias="TotalAmount")
    ]
    cfee_transactions: typing_extensions.Annotated[
        typing.List[QueryCFeeTransaction],
        FieldMetadata(alias="CfeeTransactions"),
        pydantic.Field(alias="CfeeTransactions"),
    ]
    invoice_data: typing_extensions.Annotated[
        typing.Optional[BillData], FieldMetadata(alias="invoiceData"), pydantic.Field(alias="invoiceData")
    ] = None
    transaction_events: typing_extensions.Annotated[
        typing.List[QueryTransactionEvents],
        FieldMetadata(alias="TransactionEvents"),
        pydantic.Field(alias="TransactionEvents"),
    ]
    external_paypoint_id: typing_extensions.Annotated[
        ExternalPaypointId, FieldMetadata(alias="externalPaypointID"), pydantic.Field(alias="externalPaypointID")
    ]
    is_hold: typing_extensions.Annotated[int, FieldMetadata(alias="isHold"), pydantic.Field(alias="isHold")]

    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
