# 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 pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from unicourt.model.service_status import ServiceStatus
from typing import Optional, Set
from typing_extensions import Self

class CourtServiceStatus(BaseModel):
    """
    CourtServiceStatus
    """ # noqa: E501
    object: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default='CourtServiceStatus', description="Name of the object")
    court_service_status_id: Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]] = Field(default=None, description="Court Service Status Object ID", alias="courtServiceStatusId")
    court_id_array: Optional[List[Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]]]] = Field(default=None, description="All the court ids associated to the service status", alias="courtIdArray")
    court_location_id_array: Optional[List[Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]]]] = Field(default=None, description="All the court location ids associated to the service status", alias="courtLocationIdArray")
    case_class_id_array: Optional[List[Optional[Annotated[str, Field(min_length=18, strict=True, max_length=18)]]]] = Field(default=None, description="All the Case class ids associated to the service status", alias="caseClassIdArray")
    service_status_as_on: Optional[Annotated[str, Field(min_length=25, strict=True, max_length=25)]] = Field(default=None, description="Date when the service status was last fetched.", alias="serviceStatusAsOn")
    case_update_service_status: Optional[ServiceStatus] = Field(default=None, alias="caseUpdateServiceStatus")
    case_track_service_status: Optional[ServiceStatus] = Field(default=None, alias="caseTrackServiceStatus")
    case_document_order_service_status: Optional[ServiceStatus] = Field(default=None, alias="caseDocumentOrderServiceStatus")
    __properties: ClassVar[List[str]] = ["object", "courtServiceStatusId", "courtIdArray", "courtLocationIdArray", "caseClassIdArray", "serviceStatusAsOn", "caseUpdateServiceStatus", "caseTrackServiceStatus", "caseDocumentOrderServiceStatus"]

    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 CourtServiceStatus 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 case_update_service_status
        if self.case_update_service_status:
            _dict['caseUpdateServiceStatus'] = self.case_update_service_status.to_dict()
        # override the default output from pydantic by calling `to_dict()` of case_track_service_status
        if self.case_track_service_status:
            _dict['caseTrackServiceStatus'] = self.case_track_service_status.to_dict()
        # override the default output from pydantic by calling `to_dict()` of case_document_order_service_status
        if self.case_document_order_service_status:
            _dict['caseDocumentOrderServiceStatus'] = self.case_document_order_service_status.to_dict()
        # set to None if service_status_as_on (nullable) is None
        # and model_fields_set contains the field
        if self.service_status_as_on is None and "service_status_as_on" in self.model_fields_set:
            _dict['serviceStatusAsOn'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CourtServiceStatus 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 'CourtServiceStatus',
            "courtServiceStatusId": obj.get("courtServiceStatusId"),
            "courtIdArray": obj.get("courtIdArray"),
            "courtLocationIdArray": obj.get("courtLocationIdArray"),
            "caseClassIdArray": obj.get("caseClassIdArray"),
            "serviceStatusAsOn": obj.get("serviceStatusAsOn"),
            "caseUpdateServiceStatus": ServiceStatus.from_dict(obj["caseUpdateServiceStatus"]) if obj.get("caseUpdateServiceStatus") is not None else None,
            "caseTrackServiceStatus": ServiceStatus.from_dict(obj["caseTrackServiceStatus"]) if obj.get("caseTrackServiceStatus") is not None else None,
            "caseDocumentOrderServiceStatus": ServiceStatus.from_dict(obj["caseDocumentOrderServiceStatus"]) if obj.get("caseDocumentOrderServiceStatus") is not None else None
        })
        return _obj


