# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .api_key_request_list_response_data import ApiKeyRequestListResponseData
from .api_key_response_data import ApiKeyResponseData
from .company_response_data import CompanyResponseData
from .plan_change_response_data_action import PlanChangeResponseDataAction
from .plan_change_response_data_actor_type import PlanChangeResponseDataActorType
from .plan_change_response_data_base_plan_action import PlanChangeResponseDataBasePlanAction
from .plan_change_response_data_subscription_change_action import PlanChangeResponseDataSubscriptionChangeAction
from .plan_snapshot_view import PlanSnapshotView
from .subscription_trait_update import SubscriptionTraitUpdate


class PlanChangeResponseData(UniversalBaseModel):
    action: PlanChangeResponseDataAction
    actor_type: PlanChangeResponseDataActorType
    add_ons_added: typing.List[PlanSnapshotView]
    add_ons_removed: typing.List[PlanSnapshotView]
    api_key: typing.Optional[ApiKeyResponseData] = None
    api_key_request: typing.Optional[ApiKeyRequestListResponseData] = None
    base_plan: typing.Optional[PlanSnapshotView] = None
    base_plan_action: typing.Optional[PlanChangeResponseDataBasePlanAction] = pydantic.Field(default=None)
    """
    Any special behavior that affected the assignment of the base plan during this change.
    """

    company: typing.Optional[CompanyResponseData] = None
    company_id: str
    created_at: dt.datetime
    environment_id: str
    id: str
    previous_base_plan: typing.Optional[PlanSnapshotView] = None
    request_id: typing.Optional[str] = None
    subscription_change_action: typing.Optional[PlanChangeResponseDataSubscriptionChangeAction] = pydantic.Field(
        default=None
    )
    """
    If a subscription was changed as a part of this plan change, indicates the type of change that was made.
    """

    traits_updated: typing.List[SubscriptionTraitUpdate] = pydantic.Field()
    """
    Any traits were updated as part of this plan change (via pay-in-advance entitlements).
    """

    updated_at: dt.datetime
    user_id: typing.Optional[str] = None
    user_name: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
