"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from datetime import datetime
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Dict, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


ProductObject = Literal["product",]


class ProductTypedDict(TypedDict):
    id: str
    r"""Unique identifier for a product"""
    created_at: datetime
    description: str
    merchant_id: str
    r"""Unique identifier for an organization"""
    metadata: Dict[str, str]
    name: str
    updated_at: datetime
    object: NotRequired[ProductObject]


class Product(BaseModel):
    id: str
    r"""Unique identifier for a product"""

    created_at: Annotated[datetime, pydantic.Field(alias="createdAt")]

    description: str

    merchant_id: Annotated[str, pydantic.Field(alias="merchantId")]
    r"""Unique identifier for an organization"""

    metadata: Dict[str, str]

    name: str

    updated_at: Annotated[datetime, pydantic.Field(alias="updatedAt")]

    object: Optional[ProductObject] = "product"

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["object"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    Product.model_rebuild()
except NameError:
    pass
