# 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")] = None
    customer_number: typing_extensions.Annotated[
        typing.Optional[CustomerNumberNullable], FieldMetadata(alias="customerNumber")
    ] = None
    customer_username: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="customerUsername")] = (
        pydantic.Field(default=None)
    )
    """
    Username for customer.
    """

    customer_status: typing_extensions.Annotated[
        typing.Optional[CustomerStatus], FieldMetadata(alias="customerStatus")
    ] = None
    company: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Company")] = pydantic.Field(
        default=None
    )
    """
    Company name.
    """

    firstname: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Firstname")] = pydantic.Field(
        default=None
    )
    """
    Customer first name.
    """

    lastname: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Lastname")] = pydantic.Field(
        default=None
    )
    """
    Customer last name.
    """

    phone: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Phone")] = pydantic.Field(
        default=None
    )
    """
    Customer phone number.
    """

    email: typing_extensions.Annotated[typing.Optional[Email], FieldMetadata(alias="Email")] = pydantic.Field(
        default=None
    )
    """
    Customer email address.
    """

    address: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Address")] = pydantic.Field(
        default=None
    )
    """
    Customer address.
    """

    address_1: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Address1")] = pydantic.Field(
        default=None
    )
    """
    Additional line for customer address.
    """

    city: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="City")] = pydantic.Field(default=None)
    """
    Customer city.
    """

    state: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="State")] = pydantic.Field(
        default=None
    )
    """
    Customer state.
    """

    zip: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Zip")] = pydantic.Field(default=None)
    """
    Customer postal code.
    """

    country: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="Country")] = pydantic.Field(
        default=None
    )
    """
    Customer country.
    """

    shipping_address: typing_extensions.Annotated[
        typing.Optional[Shippingaddress], FieldMetadata(alias="ShippingAddress")
    ] = None
    shipping_address_1: typing_extensions.Annotated[
        typing.Optional[Shippingaddressadditional], FieldMetadata(alias="ShippingAddress1")
    ] = None
    shipping_city: typing_extensions.Annotated[typing.Optional[Shippingcity], FieldMetadata(alias="ShippingCity")] = (
        None
    )
    shipping_state: typing_extensions.Annotated[
        typing.Optional[Shippingstate], FieldMetadata(alias="ShippingState")
    ] = None
    shipping_zip: typing_extensions.Annotated[typing.Optional[Shippingzip], FieldMetadata(alias="ShippingZip")] = None
    shipping_country: typing_extensions.Annotated[
        typing.Optional[Shippingcountry], FieldMetadata(alias="ShippingCountry")
    ] = None
    balance: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="Balance")] = pydantic.Field(
        default=None
    )
    """
    Customer balance.
    """

    time_zone: typing_extensions.Annotated[typing.Optional[Timezone], FieldMetadata(alias="TimeZone")] = None
    mfa: typing_extensions.Annotated[typing.Optional[Mfa], FieldMetadata(alias="MFA")] = None
    mfa_mode: typing_extensions.Annotated[typing.Optional[MfaMode], FieldMetadata(alias="MFAMode")] = None
    sn_provider: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="snProvider")] = pydantic.Field(
        default=None
    )
    """
    Social network linked to customer. Possible values:
    
    - `facebook`
    
    - `google`
    
    - `twitter`
    
    - `microsoft`
    """

    sn_identifier: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="snIdentifier")] = (
        pydantic.Field(default=None)
    )
    """
    Identifier or token for customer in linked social network.
    """

    sn_data: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="snData")] = pydantic.Field(
        default=None
    )
    """
    Additional data provided by the social network related to the customer.
    """

    last_updated: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="LastUpdated")] = (
        pydantic.Field(default=None)
    )
    """
    Date and time of last update.
    """

    created: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="Created")] = pydantic.Field(
        default=None
    )
    """
    Date and time created.
    """

    additional_fields: typing_extensions.Annotated[
        typing.Optional[typing.Dict[str, typing.Optional[str]]], FieldMetadata(alias="AdditionalFields")
    ] = pydantic.Field(default=None)
    """
    List of additional custom fields in format key:value.
    """

    identifier_fields: typing_extensions.Annotated[
        typing.Optional[Identifierfields], FieldMetadata(alias="IdentifierFields")
    ] = None
    subscriptions: typing_extensions.Annotated[
        typing.Optional[typing.List[SubscriptionQueryRecords]], FieldMetadata(alias="Subscriptions")
    ] = pydantic.Field(default=None)
    """
    List of subscriptions associated to the customer.
    """

    stored_methods: typing_extensions.Annotated[
        typing.Optional[typing.List[MethodQueryRecords]], FieldMetadata(alias="StoredMethods")
    ] = pydantic.Field(default=None)
    """
    List of payment methods associated to the customer.
    """

    customer_summary: typing_extensions.Annotated[
        typing.Optional[CustomerSummaryRecord], FieldMetadata(alias="customerSummary")
    ] = None
    paypoint_legalname: typing_extensions.Annotated[
        typing.Optional[Legalname], FieldMetadata(alias="PaypointLegalname")
    ] = pydantic.Field(default=None)
    """
    Paypoint legal name.
    """

    paypoint_dbaname: typing_extensions.Annotated[typing.Optional[Dbaname], FieldMetadata(alias="PaypointDbaname")] = (
        pydantic.Field(default=None)
    )
    """
    Paypoint DBA name.
    """

    parent_org_name: typing_extensions.Annotated[
        typing.Optional[OrgParentName], FieldMetadata(alias="ParentOrgName")
    ] = None
    parent_org_id: typing_extensions.Annotated[typing.Optional[OrgParentId], FieldMetadata(alias="ParentOrgId")] = None
    paypoint_entryname: typing_extensions.Annotated[
        typing.Optional[Entrypointfield], FieldMetadata(alias="PaypointEntryname")
    ] = None
    pageidentifier: typing.Optional[PageIdentifier] = None
    external_paypoint_id: typing_extensions.Annotated[
        typing.Optional[ExternalPaypointId], FieldMetadata(alias="externalPaypointID")
    ] = None
    customer_consent: typing_extensions.Annotated[
        typing.Optional[CustomerQueryRecordsCustomerConsent], FieldMetadata(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
