# coding: utf-8

"""
    UniCourt Enterprise APIs

    <button><a href=\"/developers/enterpriseapi/api/download/UniCourt-Enterprise-API-Spec.yaml\" >Download UniCourt Enterprise APIs Specification</a></button> 

    The version of the OpenAPI document: 
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class CaseType(BaseModel):
    """
    CaseType
    """ # noqa: E501
    object: Optional[Annotated[str, Field(min_length=8, strict=True, max_length=8)]] = 'CaseType'
    case_type_id: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default=None, alias="caseTypeId")
    case_class_id: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default=None, alias="caseClassId")
    area_of_law_id: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default=None, alias="areaOfLawId")
    case_type_group_id: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default=None, alias="caseTypeGroupId")
    case_class: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, alias="caseClass")
    area_of_law: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, alias="areaOfLaw")
    case_type_group: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, alias="caseTypeGroup")
    name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = None
    sali_code: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, alias="saliCode")
    case_type_tag: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, alias="caseTypeTag")
    created_date: Optional[datetime] = Field(default=None, description="The date and time when it was first created. This date and time is in UTC. Formatted as YYYY-MM-DD HH:MM:SS.", alias="createdDate")
    __properties: ClassVar[List[str]] = ["object", "caseTypeId", "caseClassId", "areaOfLawId", "caseTypeGroupId", "caseClass", "areaOfLaw", "caseTypeGroup", "name", "saliCode", "caseTypeTag", "createdDate"]

    model_config = ConfigDict(
        populate_by_name=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"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CaseType 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,
        )
        # set to None if area_of_law_id (nullable) is None
        # and model_fields_set contains the field
        if self.area_of_law_id is None and "area_of_law_id" in self.model_fields_set:
            _dict['areaOfLawId'] = None

        # set to None if case_type_group_id (nullable) is None
        # and model_fields_set contains the field
        if self.case_type_group_id is None and "case_type_group_id" in self.model_fields_set:
            _dict['caseTypeGroupId'] = None

        # set to None if area_of_law (nullable) is None
        # and model_fields_set contains the field
        if self.area_of_law is None and "area_of_law" in self.model_fields_set:
            _dict['areaOfLaw'] = None

        # set to None if case_type_group (nullable) is None
        # and model_fields_set contains the field
        if self.case_type_group is None and "case_type_group" in self.model_fields_set:
            _dict['caseTypeGroup'] = None

        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

        # set to None if sali_code (nullable) is None
        # and model_fields_set contains the field
        if self.sali_code is None and "sali_code" in self.model_fields_set:
            _dict['saliCode'] = None

        # set to None if case_type_tag (nullable) is None
        # and model_fields_set contains the field
        if self.case_type_tag is None and "case_type_tag" in self.model_fields_set:
            _dict['caseTypeTag'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "object": obj.get("object") if obj.get("object") is not None else 'CaseType',
            "caseTypeId": obj.get("caseTypeId"),
            "caseClassId": obj.get("caseClassId"),
            "areaOfLawId": obj.get("areaOfLawId"),
            "caseTypeGroupId": obj.get("caseTypeGroupId"),
            "caseClass": obj.get("caseClass"),
            "areaOfLaw": obj.get("areaOfLaw"),
            "caseTypeGroup": obj.get("caseTypeGroup"),
            "name": obj.get("name"),
            "saliCode": obj.get("saliCode"),
            "caseTypeTag": obj.get("caseTypeTag"),
            "createdDate": obj.get("createdDate")
        })
        return _obj


