"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
import dateutil.parser
from ..shared import accountingsyncconfiguration as shared_accountingsyncconfiguration
from ..shared import address as shared_address
from ..shared import customertaxid as shared_customertaxid
from ..shared import reportingconfiguration as shared_reportingconfiguration
from dataclasses_json import Undefined, dataclass_json
from datetime import datetime
from enum import Enum
from orb import utils
from typing import Optional

class CustomerPaymentProvider(str, Enum):
    r"""This is used for creating charges or invoices in an external system via Orb. When not in test mode, the connection must first be configured in the Orb webapp."""
    QUICKBOOKS = 'quickbooks'
    BILL_COM = 'bill.com'
    STRIPE_CHARGE = 'stripe_charge'
    STRIPE_INVOICE = 'stripe_invoice'
    NETSUITE = 'netsuite'


@dataclass_json(undefined=Undefined.EXCLUDE)

@dataclasses.dataclass
class Customer:
    r"""A customer is a buyer of your products, and the other party to the billing relationship.

    In Orb, customers are assigned system generated identifiers automatically, but it's often desirable to have these
    match existing identifiers in your system. To avoid having to denormalize Orb ID information, you can pass in an
    `external_customer_id` with your own identifier. See
    [Customer ID Aliases](../guides/events-and-metrics/customer-aliases) for further information about how these
    aliases work in Orb.

    In addition to having an identifier in your system, a customer may exist in a payment provider solution like
    Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to express this mapping.

    A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), which
    defaults to your account's timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for
    information on what this timezone parameter influences within Orb.
    """
    additional_emails: list[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('additional_emails') }})
    auto_collection: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('auto_collection') }})
    balance: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('balance') }})
    r"""The customer's current balance in their currency."""
    billing_address: Optional[shared_address.Address] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('billing_address') }})
    created_at: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('created_at'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse }})
    currency: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('currency') }})
    email: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('email') }})
    r"""A valid customer email, to be used for notifications. When Orb triggers payment through a payment gateway, this email will be used for any automatically issued receipts."""
    email_delivery: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('email_delivery') }})
    external_customer_id: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('external_customer_id') }})
    r"""An optional user-defined ID for this customer resource, used throughout the system as an alias for this Customer. Use this field to identify a customer by an existing identifier in your system."""
    id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }})
    metadata: dict[str, str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('metadata') }})
    name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }})
    r"""The full name of the customer"""
    payment_provider: Optional[CustomerPaymentProvider] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('payment_provider') }})
    r"""This is used for creating charges or invoices in an external system via Orb. When not in test mode, the connection must first be configured in the Orb webapp."""
    payment_provider_id: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('payment_provider_id') }})
    r"""The ID of this customer in an external payments solution, such as Stripe. This is used for creating charges or invoices in the external system via Orb."""
    portal_url: Optional[str] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('portal_url') }})
    shipping_address: Optional[shared_address.Address] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('shipping_address') }})
    tax_id: Optional[shared_customertaxid.CustomerTaxID] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('tax_id') }})
    timezone: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('timezone') }})
    r"""A timezone identifier from the IANA timezone database, such as \\"America/Los_Angeles\\". This \\"defaults to your account's timezone if not set. This cannot be changed after customer creation."""
    accounting_sync_configuration: Optional[shared_accountingsyncconfiguration.AccountingSyncConfiguration] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('accounting_sync_configuration') }})
    reporting_configuration: Optional[shared_reportingconfiguration.ReportingConfiguration] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('reporting_configuration') }})
    

