# coding: utf-8

"""
    CATAPA API

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

    The version of the OpenAPI document: 1.0.0
    Contact: support@catapa.com
    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from openapi_client.models.id_code_name_response import IdCodeNameResponse
from openapi_client.models.shift_pattern_template_simple_response import ShiftPatternTemplateSimpleResponse
from openapi_client.models.shift_response import ShiftResponse
from openapi_client.models.workday_configuration_detail_response import WorkdayConfigurationDetailResponse
from typing import Optional, Set
from typing_extensions import Self

class WorkgroupWorkdayConfigurationResponse(BaseModel):
    """
    WorkgroupWorkdayConfigurationResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    start_date: Optional[StrictStr] = Field(default=None, alias="startDate")
    end_date: Optional[StrictStr] = Field(default=None, alias="endDate")
    shift_pattern_template: Optional[ShiftPatternTemplateSimpleResponse] = Field(default=None, alias="shiftPatternTemplate")
    workday_configuration_details: Optional[List[WorkdayConfigurationDetailResponse]] = Field(default=None, alias="workdayConfigurationDetails")
    start_sequence: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="startSequence")
    start_shift: Optional[ShiftResponse] = Field(default=None, alias="startShift")
    include_holiday: Optional[StrictBool] = Field(default=None, alias="includeHoliday")
    workgroup: Optional[IdCodeNameResponse] = None
    __properties: ClassVar[List[str]] = ["id", "startDate", "endDate", "shiftPatternTemplate", "workdayConfigurationDetails", "startSequence", "startShift", "includeHoliday", "workgroup"]

    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 WorkgroupWorkdayConfigurationResponse 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 shift_pattern_template
        if self.shift_pattern_template:
            _dict['shiftPatternTemplate'] = self.shift_pattern_template.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in workday_configuration_details (list)
        _items = []
        if self.workday_configuration_details:
            for _item_workday_configuration_details in self.workday_configuration_details:
                if _item_workday_configuration_details:
                    _items.append(_item_workday_configuration_details.to_dict())
            _dict['workdayConfigurationDetails'] = _items
        # override the default output from pydantic by calling `to_dict()` of start_shift
        if self.start_shift:
            _dict['startShift'] = self.start_shift.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workgroup
        if self.workgroup:
            _dict['workgroup'] = self.workgroup.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "startDate": obj.get("startDate"),
            "endDate": obj.get("endDate"),
            "shiftPatternTemplate": ShiftPatternTemplateSimpleResponse.from_dict(obj["shiftPatternTemplate"]) if obj.get("shiftPatternTemplate") is not None else None,
            "workdayConfigurationDetails": [WorkdayConfigurationDetailResponse.from_dict(_item) for _item in obj["workdayConfigurationDetails"]] if obj.get("workdayConfigurationDetails") is not None else None,
            "startSequence": obj.get("startSequence"),
            "startShift": ShiftResponse.from_dict(obj["startShift"]) if obj.get("startShift") is not None else None,
            "includeHoliday": obj.get("includeHoliday"),
            "workgroup": IdCodeNameResponse.from_dict(obj["workgroup"]) if obj.get("workgroup") is not None else None
        })
        return _obj


