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

from __future__ import annotations
from .github_com_flexprice_flexprice_internal_domain_coupon_coupon import (
    GithubComFlexpriceFlexpriceInternalDomainCouponCoupon,
    GithubComFlexpriceFlexpriceInternalDomainCouponCouponTypedDict,
)
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 DtoCouponAssociationResponseTypedDict(TypedDict):
    coupon: NotRequired[GithubComFlexpriceFlexpriceInternalDomainCouponCouponTypedDict]
    coupon_id: NotRequired[str]
    created_at: NotRequired[str]
    created_by: NotRequired[str]
    end_date: NotRequired[str]
    r"""Optional"""
    environment_id: NotRequired[str]
    id: NotRequired[str]
    metadata: NotRequired[Dict[str, str]]
    start_date: NotRequired[str]
    status: NotRequired[Status]
    subscription_id: NotRequired[str]
    r"""Mandatory"""
    subscription_line_item_id: NotRequired[str]
    r"""Optional"""
    subscription_phase_id: NotRequired[str]
    r"""Optional"""
    tenant_id: NotRequired[str]
    updated_at: NotRequired[str]
    updated_by: NotRequired[str]


class DtoCouponAssociationResponse(BaseModel):
    coupon: Optional[GithubComFlexpriceFlexpriceInternalDomainCouponCoupon] = None

    coupon_id: Optional[str] = None

    created_at: Optional[str] = None

    created_by: Optional[str] = None

    end_date: Optional[str] = None
    r"""Optional"""

    environment_id: Optional[str] = None

    id: Optional[str] = None

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

    start_date: Optional[str] = None

    status: Optional[Status] = None

    subscription_id: Optional[str] = None
    r"""Mandatory"""

    subscription_line_item_id: Optional[str] = None
    r"""Optional"""

    subscription_phase_id: Optional[str] = None
    r"""Optional"""

    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(
            [
                "coupon",
                "coupon_id",
                "created_at",
                "created_by",
                "end_date",
                "environment_id",
                "id",
                "metadata",
                "start_date",
                "status",
                "subscription_id",
                "subscription_line_item_id",
                "subscription_phase_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
