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

from __future__ import annotations
from .status import Status
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 DtoSubscriptionPhaseResponseTypedDict(TypedDict):
    created_at: NotRequired[str]
    created_by: NotRequired[str]
    end_date: NotRequired[str]
    r"""EndDate is when the phase ends (nil if phase is still active or indefinite)"""
    environment_id: NotRequired[str]
    r"""EnvironmentID is the environment identifier for the phase"""
    id: NotRequired[str]
    r"""ID is the unique identifier for the subscription phase"""
    metadata: NotRequired[Dict[str, str]]
    start_date: NotRequired[str]
    r"""StartDate is when the phase starts"""
    status: NotRequired[Status]
    subscription_id: NotRequired[str]
    r"""SubscriptionID is the identifier for the subscription"""
    tenant_id: NotRequired[str]
    updated_at: NotRequired[str]
    updated_by: NotRequired[str]


class DtoSubscriptionPhaseResponse(BaseModel):
    created_at: Optional[str] = None

    created_by: Optional[str] = None

    end_date: Optional[str] = None
    r"""EndDate is when the phase ends (nil if phase is still active or indefinite)"""

    environment_id: Optional[str] = None
    r"""EnvironmentID is the environment identifier for the phase"""

    id: Optional[str] = None
    r"""ID is the unique identifier for the subscription phase"""

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

    start_date: Optional[str] = None
    r"""StartDate is when the phase starts"""

    status: Optional[Status] = None

    subscription_id: Optional[str] = None
    r"""SubscriptionID is the identifier for the subscription"""

    tenant_id: Optional[str] = None

    updated_at: Optional[str] = None

    updated_by: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "created_at",
                "created_by",
                "end_date",
                "environment_id",
                "id",
                "metadata",
                "start_date",
                "status",
                "subscription_id",
                "tenant_id",
                "updated_at",
                "updated_by",
            ]
        )
        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
