# 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, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from unicourt.model.case_class_coverage import CaseClassCoverage
from unicourt.model.court import Court
from typing import Optional, Set
from typing_extensions import Self

class CourtCoverage(BaseModel):
    """
    CourtCoverage
    """ # noqa: E501
    object: Optional[Annotated[str, Field(min_length=13, strict=True, max_length=13)]] = Field(default='CourtCoverage', description="Name of the object")
    last_update_count_date: Optional[Annotated[str, Field(min_length=25, strict=True, max_length=25)]] = Field(default=None, description="Date when it was last updated.", alias="lastUpdateCountDate")
    court: Optional[Court] = None
    total_case_count: Optional[StrictInt] = Field(default=None, description="Total Cases for a specific court.", alias="totalCaseCount")
    total_cases_in_last_thirty_days_count: Optional[StrictInt] = Field(default=None, description="Total Cases in last 30 days that were added to UniCourt", alias="totalCasesInLastThirtyDaysCount")
    total_free_case_document_count: Optional[StrictInt] = Field(default=None, description="Total Free Case Documents for a specific court.", alias="totalFreeCaseDocumentCount")
    total_free_case_documents_in_last_thirty_days_count: Optional[StrictInt] = Field(default=None, description="Total Free Case Documents in last 30 days that were added to UniCourt", alias="totalFreeCaseDocumentsInLastThirtyDaysCount")
    total_paid_case_document_count: Optional[StrictInt] = Field(default=None, description="Total Paid Case Documents for a specific court.", alias="totalPaidCaseDocumentCount")
    total_paid_case_documents_in_last_thirty_days_count: Optional[StrictInt] = Field(default=None, description="Total Paid Case Documents in last 30 days that were added to UniCourt", alias="totalPaidCaseDocumentsInLastThirtyDaysCount")
    total_case_document_in_library_count: Optional[StrictInt] = Field(default=None, description="Count of total Case Documents added in UniCourt Library.", alias="totalCaseDocumentInLibraryCount")
    total_case_document_in_library_in_last_thirty_days_count: Optional[StrictInt] = Field(default=None, description="Count of total Case Documents added in UniCourt Library in last 30 days", alias="totalCaseDocumentInLibraryInLastThirtyDaysCount")
    case_class_coverage_array: Optional[List[CaseClassCoverage]] = Field(default=None, alias="caseClassCoverageArray")
    __properties: ClassVar[List[str]] = ["object", "lastUpdateCountDate", "court", "totalCaseCount", "totalCasesInLastThirtyDaysCount", "totalFreeCaseDocumentCount", "totalFreeCaseDocumentsInLastThirtyDaysCount", "totalPaidCaseDocumentCount", "totalPaidCaseDocumentsInLastThirtyDaysCount", "totalCaseDocumentInLibraryCount", "totalCaseDocumentInLibraryInLastThirtyDaysCount", "caseClassCoverageArray"]

    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 CourtCoverage 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 court
        if self.court:
            _dict['court'] = self.court.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in case_class_coverage_array (list)
        _items = []
        if self.case_class_coverage_array:
            for _item in self.case_class_coverage_array:
                if _item:
                    _items.append(_item.to_dict())
            _dict['caseClassCoverageArray'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CourtCoverage 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 'CourtCoverage',
            "lastUpdateCountDate": obj.get("lastUpdateCountDate"),
            "court": Court.from_dict(obj["court"]) if obj.get("court") is not None else None,
            "totalCaseCount": obj.get("totalCaseCount"),
            "totalCasesInLastThirtyDaysCount": obj.get("totalCasesInLastThirtyDaysCount"),
            "totalFreeCaseDocumentCount": obj.get("totalFreeCaseDocumentCount"),
            "totalFreeCaseDocumentsInLastThirtyDaysCount": obj.get("totalFreeCaseDocumentsInLastThirtyDaysCount"),
            "totalPaidCaseDocumentCount": obj.get("totalPaidCaseDocumentCount"),
            "totalPaidCaseDocumentsInLastThirtyDaysCount": obj.get("totalPaidCaseDocumentsInLastThirtyDaysCount"),
            "totalCaseDocumentInLibraryCount": obj.get("totalCaseDocumentInLibraryCount"),
            "totalCaseDocumentInLibraryInLastThirtyDaysCount": obj.get("totalCaseDocumentInLibraryInLastThirtyDaysCount"),
            "caseClassCoverageArray": [CaseClassCoverage.from_dict(_item) for _item in obj["caseClassCoverageArray"]] if obj.get("caseClassCoverageArray") is not None else None
        })
        return _obj


