# 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, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class CaseCountAnalyticsByCaseFiledDate(BaseModel):
    """
    CaseCountAnalyticsByCaseFiledDate
    """ # noqa: E501
    object: Optional[Annotated[str, Field(strict=True, max_length=33)]] = 'CaseCountAnalyticsByCaseFiledDate'
    case_count: Optional[StrictInt] = Field(default=None, alias="caseCount")
    case_search_api: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Link to cases for this criteria.", alias="caseSearchAPI")
    grouped_by: Optional[Annotated[str, Field(strict=True, max_length=9)]] = Field(default='Yearly', alias="groupedBy")
    year: Optional[StrictInt] = None
    quarter: Optional[Annotated[str, Field(strict=True, max_length=4)]] = None
    month_string: Optional[Annotated[str, Field(strict=True, max_length=9)]] = Field(default=None, alias="monthString")
    month_int: Optional[StrictInt] = Field(default=None, alias="monthInt")
    week_of_year: Optional[StrictInt] = Field(default=None, alias="weekOfYear")
    week_of_month: Optional[StrictInt] = Field(default=None, alias="weekOfMonth")
    __properties: ClassVar[List[str]] = ["object", "caseCount", "caseSearchAPI", "groupedBy", "year", "quarter", "monthString", "monthInt", "weekOfYear", "weekOfMonth"]

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

        if value not in set(['Yearly', 'Quarterly', 'Monthly', 'Weekly']):
            raise ValueError("must be one of enum values ('Yearly', 'Quarterly', 'Monthly', 'Weekly')")
        return value

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

        if value not in set(['Q1', 'Q2', 'Q3', 'Q4', 'null']):
            raise ValueError("must be one of enum values ('Q1', 'Q2', 'Q3', 'Q4', 'null')")
        return value

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

        if value not in set(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'null']):
            raise ValueError("must be one of enum values ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'null')")
        return value

    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 CaseCountAnalyticsByCaseFiledDate 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 quarter (nullable) is None
        # and model_fields_set contains the field
        if self.quarter is None and "quarter" in self.model_fields_set:
            _dict['quarter'] = None

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CaseCountAnalyticsByCaseFiledDate 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 'CaseCountAnalyticsByCaseFiledDate',
            "caseCount": obj.get("caseCount"),
            "caseSearchAPI": obj.get("caseSearchAPI"),
            "groupedBy": obj.get("groupedBy") if obj.get("groupedBy") is not None else 'Yearly',
            "year": obj.get("year"),
            "quarter": obj.get("quarter"),
            "monthString": obj.get("monthString"),
            "monthInt": obj.get("monthInt"),
            "weekOfYear": obj.get("weekOfYear"),
            "weekOfMonth": obj.get("weekOfMonth")
        })
        return _obj


