# 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 .customer_id import CustomerId
from .customer_number_nullable import CustomerNumberNullable
from .customer_query_records_customer_consent import CustomerQueryRecordsCustomerConsent
from .customer_status import CustomerStatus
from .customer_summary_record import CustomerSummaryRecord
from .dbaname import Dbaname
from .email import Email
from .entrypointfield import Entrypointfield
from .external_paypoint_id import ExternalPaypointId
from .identifierfields import Identifierfields
from .legalname import Legalname
from .method_query_records import MethodQueryRecords
from .mfa import Mfa
from .mfa_mode import MfaMode
from .org_parent_id import OrgParentId
from .org_parent_name import OrgParentName
from .page_identifier import PageIdentifier
from .shippingaddress import Shippingaddress
from .shippingaddressadditional import Shippingaddressadditional
from .shippingcity import Shippingcity
from .shippingcountry import Shippingcountry
from .shippingstate import Shippingstate
from .shippingzip import Shippingzip
from .subscription_query_records import SubscriptionQueryRecords
from .timezone import Timezone


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

    from payabli import (
        BinData,
        CustomerQueryRecords,
        CustomerQueryRecordsCustomerConsent,
        CustomerQueryRecordsCustomerConsentECommunication,
        CustomerQueryRecordsCustomerConsentSms,
        CustomerSummaryRecord,
        GeneralEvents,
        MethodQueryRecords,
        PaymentDetail,
        QueryPaymentData,
        SubscriptionQueryRecords,
        TransactionQueryRecords,
    )

    CustomerQueryRecords(
        customer_id=4440,
        customer_number="3456-7645A",
        customer_username="myusername",
        customer_status=1,
        company="AA LLC",
        firstname="John",
        lastname="Smith",
        phone="1234567890",
        email="example@email.com",
        address="3245 Main St",
        address_1="STE 900",
        city="Miami",
        state="FL",
        zip="77777",
        country="US",
        shipping_address="123 Walnut St",
        shipping_address_1="STE 900",
        shipping_city="Johnson City",
        shipping_state="TN",
        shipping_zip="37619",
        shipping_country="US",
        balance=1.1,
        time_zone=-5,
        mfa=False,
        mfa_mode=0,
        sn_provider="facebook",
        sn_identifier="6677fgttyudd999",
        sn_data="",
        last_updated=datetime.datetime.fromisoformat(
            "2021-06-16 05:00:00+00:00",
        ),
        created=datetime.datetime.fromisoformat(
            "2021-06-10 05:00:00+00:00",
        ),
        additional_fields={"property1": "string", "property2": "string"},
        identifier_fields=["email"],
        subscriptions=[
            SubscriptionQueryRecords(
                created_at=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
                end_date=datetime.datetime.fromisoformat(
                    "2025-10-19 00:00:00+00:00",
                ),
                entrypage_id=0,
                external_paypoint_id="Paypoint-100",
                fee_amount=3.0,
                frequency="monthly",
                id_sub=396,
                last_run=datetime.datetime.fromisoformat(
                    "2025-10-19 00:00:00+00:00",
                ),
                last_updated=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
                left_cycles=15,
                method="card",
                net_amount=3762.87,
                next_date=datetime.datetime.fromisoformat(
                    "2025-10-19 00:00:00+00:00",
                ),
                parent_org_name="PropertyManager Pro",
                payment_data=QueryPaymentData(
                    payment_details=PaymentDetail(
                        total_amount=100.0,
                    ),
                ),
                paypoint_dbaname="Sunshine Gutters",
                paypoint_entryname="d193cf9a46",
                paypoint_id=255,
                paypoint_legalname="Sunshine Services, LLC",
                plan_id=0,
                source="api",
                start_date=datetime.datetime.fromisoformat(
                    "2025-10-19 00:00:00+00:00",
                ),
                sub_events=[
                    GeneralEvents(
                        description="TransferCreated",
                        event_time=datetime.datetime.fromisoformat(
                            "2023-07-05 22:31:06+00:00",
                        ),
                    )
                ],
                sub_status=1,
                total_amount=103.0,
                total_cycles=24,
                until_cancelled=True,
            )
        ],
        stored_methods=[
            MethodQueryRecords(
                bin="411111",
                bin_data=BinData(
                    bin_matched_length="6",
                    bin_card_brand="Visa",
                    bin_card_type="Credit",
                    bin_card_category="PLATINUM",
                    bin_card_issuer="Bank of Example",
                    bin_card_issuer_country="United States",
                    bin_card_issuer_country_code_a_2="US",
                    bin_card_issuer_country_number="840",
                    bin_card_is_regulated="false",
                    bin_card_use_category="Consumer",
                    bin_card_issuer_country_code_a_3="USA",
                ),
                descriptor="visa",
                exp_date="1227",
                holder_name="Chad Mercia",
                id_pmethod="6edcbb56-9c0e-4003-b3d1-99abf149ba0e",
                last_updated=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
                masked_account="4XXXXXXXX1111",
                method="card",
            )
        ],
        customer_summary=CustomerSummaryRecord(
            numberof_transactions=30,
            recent_transactions=[
                TransactionQueryRecords(
                    entrypage_id=0,
                    fee_amount=1.0,
                    payor_id=1551,
                    paypoint_id=226,
                    settlement_status=2,
                    total_amount=30.22,
                    trans_status=1,
                )
            ],
            total_amount_transactions=1500.0,
            total_net_amount_transactions=1500.0,
        ),
        paypoint_legalname="Sunshine Services, LLC",
        paypoint_dbaname="Sunshine Gutters",
        parent_org_name="PropertyManager Pro",
        parent_org_id=123,
        paypoint_entryname="d193cf9a46",
        pageidentifier="null",
        external_paypoint_id="Paypoint-100",
        customer_consent=CustomerQueryRecordsCustomerConsent(
            e_communication=CustomerQueryRecordsCustomerConsentECommunication(
                status=1,
                updated_at=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
            ),
            sms=CustomerQueryRecordsCustomerConsentSms(
                status=1,
                updated_at=datetime.datetime.fromisoformat(
                    "2022-07-01 15:00:01+00:00",
                ),
            ),
        ),
    )
    """

    customer_id: typing_extensions.Annotated[
        typing.Optional[CustomerId], FieldMetadata(alias="customerId"), pydantic.Field(alias="customerId")
    ] = None
    customer_number: typing_extensions.Annotated[
        typing.Optional[CustomerNumberNullable],
        FieldMetadata(alias="customerNumber"),
        pydantic.Field(alias="customerNumber"),
    ] = None
    customer_username: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="customerUsername"),
        pydantic.Field(alias="customerUsername", description="Username for customer."),
    ] = None
    customer_status: typing_extensions.Annotated[
        typing.Optional[CustomerStatus], FieldMetadata(alias="customerStatus"), pydantic.Field(alias="customerStatus")
    ] = None
    company: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Company"),
        pydantic.Field(alias="Company", description="Company name."),
    ] = None
    firstname: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Firstname"),
        pydantic.Field(alias="Firstname", description="Customer first name."),
    ] = None
    lastname: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Lastname"),
        pydantic.Field(alias="Lastname", description="Customer last name."),
    ] = None
    phone: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Phone"),
        pydantic.Field(alias="Phone", description="Customer phone number."),
    ] = None
    email: typing_extensions.Annotated[
        typing.Optional[Email],
        FieldMetadata(alias="Email"),
        pydantic.Field(alias="Email", description="Customer email address."),
    ] = None
    address: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Address"),
        pydantic.Field(alias="Address", description="Customer address."),
    ] = None
    address_1: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Address1"),
        pydantic.Field(alias="Address1", description="Additional line for customer address."),
    ] = None
    city: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="City"), pydantic.Field(alias="City", description="Customer city.")
    ] = None
    state: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="State"), pydantic.Field(alias="State", description="Customer state.")
    ] = None
    zip: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Zip"),
        pydantic.Field(alias="Zip", description="Customer postal code."),
    ] = None
    country: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="Country"),
        pydantic.Field(alias="Country", description="Customer country."),
    ] = None
    shipping_address: typing_extensions.Annotated[
        typing.Optional[Shippingaddress],
        FieldMetadata(alias="ShippingAddress"),
        pydantic.Field(alias="ShippingAddress"),
    ] = None
    shipping_address_1: typing_extensions.Annotated[
        typing.Optional[Shippingaddressadditional],
        FieldMetadata(alias="ShippingAddress1"),
        pydantic.Field(alias="ShippingAddress1"),
    ] = None
    shipping_city: typing_extensions.Annotated[
        typing.Optional[Shippingcity], FieldMetadata(alias="ShippingCity"), pydantic.Field(alias="ShippingCity")
    ] = None
    shipping_state: typing_extensions.Annotated[
        typing.Optional[Shippingstate], FieldMetadata(alias="ShippingState"), pydantic.Field(alias="ShippingState")
    ] = None
    shipping_zip: typing_extensions.Annotated[
        typing.Optional[Shippingzip], FieldMetadata(alias="ShippingZip"), pydantic.Field(alias="ShippingZip")
    ] = None
    shipping_country: typing_extensions.Annotated[
        typing.Optional[Shippingcountry],
        FieldMetadata(alias="ShippingCountry"),
        pydantic.Field(alias="ShippingCountry"),
    ] = None
    balance: typing_extensions.Annotated[
        typing.Optional[float],
        FieldMetadata(alias="Balance"),
        pydantic.Field(alias="Balance", description="Customer balance."),
    ] = None
    time_zone: typing_extensions.Annotated[
        typing.Optional[Timezone], FieldMetadata(alias="TimeZone"), pydantic.Field(alias="TimeZone")
    ] = None
    mfa: typing_extensions.Annotated[typing.Optional[Mfa], FieldMetadata(alias="MFA"), pydantic.Field(alias="MFA")] = (
        None
    )
    mfa_mode: typing_extensions.Annotated[
        typing.Optional[MfaMode], FieldMetadata(alias="MFAMode"), pydantic.Field(alias="MFAMode")
    ] = None
    sn_provider: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="snProvider"),
        pydantic.Field(
            alias="snProvider",
            description="Social network linked to customer. Possible values:\n\n- `facebook`\n\n- `google`\n\n- `twitter`\n\n- `microsoft`",
        ),
    ] = None
    sn_identifier: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="snIdentifier"),
        pydantic.Field(alias="snIdentifier", description="Identifier or token for customer in linked social network."),
    ] = None
    sn_data: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="snData"),
        pydantic.Field(
            alias="snData", description="Additional data provided by the social network related to the customer."
        ),
    ] = None
    last_updated: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="LastUpdated"),
        pydantic.Field(alias="LastUpdated", description="Date and time of last update."),
    ] = None
    created: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="Created"),
        pydantic.Field(alias="Created", description="Date and time created."),
    ] = None
    additional_fields: typing_extensions.Annotated[
        typing.Optional[typing.Dict[str, typing.Optional[str]]],
        FieldMetadata(alias="AdditionalFields"),
        pydantic.Field(alias="AdditionalFields", description="List of additional custom fields in format key:value."),
    ] = None
    identifier_fields: typing_extensions.Annotated[
        typing.Optional[Identifierfields],
        FieldMetadata(alias="IdentifierFields"),
        pydantic.Field(alias="IdentifierFields"),
    ] = None
    subscriptions: typing_extensions.Annotated[
        typing.Optional[typing.List[SubscriptionQueryRecords]],
        FieldMetadata(alias="Subscriptions"),
        pydantic.Field(alias="Subscriptions", description="List of subscriptions associated to the customer."),
    ] = None
    stored_methods: typing_extensions.Annotated[
        typing.Optional[typing.List[MethodQueryRecords]],
        FieldMetadata(alias="StoredMethods"),
        pydantic.Field(alias="StoredMethods", description="List of payment methods associated to the customer."),
    ] = None
    customer_summary: typing_extensions.Annotated[
        typing.Optional[CustomerSummaryRecord],
        FieldMetadata(alias="customerSummary"),
        pydantic.Field(alias="customerSummary"),
    ] = None
    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname],
        FieldMetadata(alias="PaypointLegalname"),
        pydantic.Field(alias="PaypointLegalname", description="Paypoint legal name."),
    ] = None
    paypoint_dbaname: typing_extensions.Annotated[
        typing.Optional[Dbaname],
        FieldMetadata(alias="PaypointDbaname"),
        pydantic.Field(alias="PaypointDbaname", description="Paypoint DBA name."),
    ] = None
    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName"), pydantic.Field(alias="ParentOrgName")
    ] = None
    parent_org_id: typing_extensions.Annotated[
        typing.Optional[OrgParentId], FieldMetadata(alias="ParentOrgId"), pydantic.Field(alias="ParentOrgId")
    ] = None
    paypoint_entryname: typing_extensions.Annotated[
        typing.Optional[Entrypointfield],
        FieldMetadata(alias="PaypointEntryname"),
        pydantic.Field(alias="PaypointEntryname"),
    ] = None
    pageidentifier: typing.Optional[PageIdentifier] = None
    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[ExternalPaypointId],
        FieldMetadata(alias="externalPaypointID"),
        pydantic.Field(alias="externalPaypointID"),
    ] = None
    customer_consent: typing_extensions.Annotated[
        typing.Optional[CustomerQueryRecordsCustomerConsent],
        FieldMetadata(alias="customerConsent"),
        pydantic.Field(alias="customerConsent"),
    ] = 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
