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

import datetime as dt
import typing

from ......core.datetime_utils import serialize_datetime
from .....commons.types.organization_id import OrganizationId
from .....commons.types.patient_external_id import PatientExternalId
from .invoice_destination_metadata import InvoiceDestinationMetadata
from .invoice_item_info import InvoiceItemInfo
from .invoice_status import InvoiceStatus

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class Invoice(pydantic.BaseModel):
    amount_cents: int = pydantic.Field(description="Total monetary amount (in cents) of all Invoice Items")
    created_at: dt.datetime
    updated_at: dt.datetime
    organization_id: OrganizationId
    invoice_destination_metadata: InvoiceDestinationMetadata = pydantic.Field(
        description="Contains all relevant information from the third-party service this invoice was created in"
    )
    patient_external_id: PatientExternalId
    note: typing.Optional[str] = None
    due_date: dt.date
    status: InvoiceStatus
    url: typing.Optional[str] = pydantic.Field(
        default=None, description="Link to the admin view of the invoice in the third-party service"
    )
    customer_invoice_url: typing.Optional[str] = pydantic.Field(
        default=None, description="Link to the patient view of the invoice in the third-party service"
    )
    items: InvoiceItemInfo = pydantic.Field(
        description="The InvoiceItem rollup which contains all claim and service line invoice items"
    )

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        json_encoders = {dt.datetime: serialize_datetime}
