# coding: utf-8

"""
    ReportingService

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

    The version of the OpenAPI document: 1.0.0
    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.reporting.model_date import ModelDate
from openapi_client.models.reporting.report_time_period import ReportTimePeriod
from openapi_client.models.reporting.report_time_zone import ReportTimeZone
from typing_extensions import Self

class ReportTime(BaseModel):
    """
    ReportTime
    """ # noqa: E501
    predefined_time: Optional[ReportTimePeriod] = Field(default=None, alias="PredefinedTime")
    custom_date_range_start: Optional[ModelDate] = Field(default=None, alias="CustomDateRangeStart")
    custom_date_range_end: Optional[ModelDate] = Field(default=None, alias="CustomDateRangeEnd")
    report_time_zone: Optional[ReportTimeZone] = Field(default=None, alias="ReportTimeZone")
    __properties: ClassVar[List[str]] = ["PredefinedTime", "CustomDateRangeStart", "CustomDateRangeEnd", "ReportTimeZone"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

    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 custom_date_range_start
        if self.custom_date_range_start:
            _dict['CustomDateRangeStart'] = self.custom_date_range_start.to_dict()
        # override the default output from pydantic by calling `to_dict()` of custom_date_range_end
        if self.custom_date_range_end:
            _dict['CustomDateRangeEnd'] = self.custom_date_range_end.to_dict()
        # set to None if predefined_time (nullable) is None
        # and model_fields_set contains the field
        if self.predefined_time is None and "predefined_time" in self.model_fields_set:
            _dict['PredefinedTime'] = None

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "PredefinedTime": obj.get("PredefinedTime") if obj.get("PredefinedTime") is not None else None,
                        "CustomDateRangeStart": ModelDate.from_dict(obj["CustomDateRangeStart"]) if obj.get("CustomDateRangeStart") is not None else None,
                        "CustomDateRangeEnd": ModelDate.from_dict(obj["CustomDateRangeEnd"]) if obj.get("CustomDateRangeEnd") is not None else None,
                        "ReportTimeZone": obj.get("ReportTimeZone") if obj.get("ReportTimeZone") is not None else None
        })
        return _obj
