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

from __future__ import annotations
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class DtoClonePlanRequestTypedDict(TypedDict):
    description: NotRequired[str]
    r"""Description overrides the source plan's description when provided"""
    display_order: NotRequired[int]
    r"""DisplayOrder overrides the source plan's display order when provided"""
    lookup_key: NotRequired[str]
    r"""LookupKey is required and must be unique across published plans"""
    metadata: NotRequired[Dict[str, str]]
    name: NotRequired[str]
    r"""Name is required and must be different from the source plan's name"""


class DtoClonePlanRequest(BaseModel):
    description: Optional[str] = None
    r"""Description overrides the source plan's description when provided"""

    display_order: Optional[int] = None
    r"""DisplayOrder overrides the source plan's display order when provided"""

    lookup_key: Optional[str] = None
    r"""LookupKey is required and must be unique across published plans"""

    metadata: Optional[Dict[str, str]] = None

    name: Optional[str] = None
    r"""Name is required and must be different from the source plan's name"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["description", "display_order", "lookup_key", "metadata", "name"]
        )
        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
