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

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


class DtoPauseSubscriptionRequestTypedDict(TypedDict):
    r"""Request object for pausing an active subscription with various pause modes and options"""

    pause_mode: PauseMode
    dry_run: NotRequired[bool]
    r"""Whether to perform a dry run
    @Description If true, validates the request and shows impact without actually pausing the subscription
    @Example false
    """
    metadata: NotRequired[Dict[str, str]]
    r"""Additional metadata as key-value pairs
    @Description Optional metadata for storing additional information about the pause
    @Example {\"requested_by\": \"customer\", \"channel\": \"support_ticket\"}
    """
    pause_days: NotRequired[int]
    r"""Duration of the pause in days
    @Description Number of days to pause the subscription. Cannot be used together with pause_end. Must be greater than 0
    @Example 30
    """
    pause_end: NotRequired[str]
    r"""End date for the subscription pause
    @Description ISO 8601 timestamp when the pause should end. Cannot be used together with pause_days. Must be after pause_start
    @Example \"2024-02-15T00:00:00Z\" 
    """
    pause_start: NotRequired[str]
    r"""Start date for the subscription pause
    @Description ISO 8601 timestamp when the pause should begin. Required when pause_mode is \"scheduled\" 
    @Example \"2024-01-15T00:00:00Z\" 
    """
    reason: NotRequired[str]
    r"""Reason for pausing the subscription
    @Description Optional reason for the pause. Maximum 255 characters
    @Example \"Customer requested temporary suspension\" 
    """


class DtoPauseSubscriptionRequest(BaseModel):
    r"""Request object for pausing an active subscription with various pause modes and options"""

    pause_mode: PauseMode

    dry_run: Optional[bool] = None
    r"""Whether to perform a dry run
    @Description If true, validates the request and shows impact without actually pausing the subscription
    @Example false
    """

    metadata: Optional[Dict[str, str]] = None
    r"""Additional metadata as key-value pairs
    @Description Optional metadata for storing additional information about the pause
    @Example {\"requested_by\": \"customer\", \"channel\": \"support_ticket\"}
    """

    pause_days: Optional[int] = None
    r"""Duration of the pause in days
    @Description Number of days to pause the subscription. Cannot be used together with pause_end. Must be greater than 0
    @Example 30
    """

    pause_end: Optional[str] = None
    r"""End date for the subscription pause
    @Description ISO 8601 timestamp when the pause should end. Cannot be used together with pause_days. Must be after pause_start
    @Example \"2024-02-15T00:00:00Z\" 
    """

    pause_start: Optional[str] = None
    r"""Start date for the subscription pause
    @Description ISO 8601 timestamp when the pause should begin. Required when pause_mode is \"scheduled\" 
    @Example \"2024-01-15T00:00:00Z\" 
    """

    reason: Optional[str] = None
    r"""Reason for pausing the subscription
    @Description Optional reason for the pause. Maximum 255 characters
    @Example \"Customer requested temporary suspension\" 
    """

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["dry_run", "metadata", "pause_days", "pause_end", "pause_start", "reason"]
        )
        serialized = handler(self)
        m = {}

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

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

        return m
