# coding: utf-8

"""
    SmartyMeet Dev03 API REST

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.1
    Contact: developer@smartymeet.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from smartytalent_client.models.timeline_attributes_schema_changes_value import TimelineAttributesSchemaChangesValue
from smartytalent_client.models.timeline_attributes_schema_summary_value import TimelineAttributesSchemaSummaryValue
from smartytalent_client.models.timeline_attributes_schema_timestamps import TimelineAttributesSchemaTimestamps
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class TimelineAttributesSchema(BaseModel):
    """
    TimelineAttributesSchema
    """ # noqa: E501
    entity_type: Optional[StrictStr] = Field(default=None, description="The type of entity this timeline entry refers to (e.g., \"jobs\", \"candidates\")", alias="entityType")
    entity_id: Optional[StrictStr] = Field(default=None, description="The ID of the entity this timeline entry refers to", alias="entityId")
    action: Optional[StrictStr] = Field(default=None, description="The type of change that was made")
    user_id: Optional[StrictStr] = Field(default=None, description="The ID of the user who made the change", alias="userId")
    changes: Optional[Dict[str, TimelineAttributesSchemaChangesValue]] = Field(default=None, description="A map of changed fields with old and new values")
    summary: Optional[Dict[str, TimelineAttributesSchemaSummaryValue]] = Field(default=None, description="AI-generated summary of the change, keyed by locale (e.g., \"en-US\")")
    timestamps: Optional[TimelineAttributesSchemaTimestamps] = None
    __properties: ClassVar[List[str]] = ["entityType", "entityId", "action", "userId", "changes", "summary", "timestamps"]

    @field_validator('entity_type')
    def entity_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['jobs', 'candidates']):
            raise ValueError("must be one of enum values ('jobs', 'candidates')")
        return value

    @field_validator('action')
    def action_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['INSERT', 'MODIFY', 'REMOVE']):
            raise ValueError("must be one of enum values ('INSERT', 'MODIFY', 'REMOVE')")
        return value

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of TimelineAttributesSchema from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each value in changes (dict)
        _field_dict = {}
        if self.changes:
            for _key_changes in self.changes:
                if self.changes[_key_changes]:
                    _field_dict[_key_changes] = self.changes[_key_changes].to_dict()
            _dict['changes'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of each value in summary (dict)
        _field_dict = {}
        if self.summary:
            for _key_summary in self.summary:
                if self.summary[_key_summary]:
                    _field_dict[_key_summary] = self.summary[_key_summary].to_dict()
            _dict['summary'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of timestamps
        if self.timestamps:
            _dict['timestamps'] = self.timestamps.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of TimelineAttributesSchema from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "entityType": obj.get("entityType"),
            "entityId": obj.get("entityId"),
            "action": obj.get("action"),
            "userId": obj.get("userId"),
            "changes": dict(
                (_k, TimelineAttributesSchemaChangesValue.from_dict(_v))
                for _k, _v in obj["changes"].items()
            )
            if obj.get("changes") is not None
            else None,
            "summary": dict(
                (_k, TimelineAttributesSchemaSummaryValue.from_dict(_v))
                for _k, _v in obj["summary"].items()
            )
            if obj.get("summary") is not None
            else None,
            "timestamps": TimelineAttributesSchemaTimestamps.from_dict(obj["timestamps"]) if obj.get("timestamps") is not None else None
        })
        return _obj


