# coding: utf-8

"""
    CATAPA API

    CATAPA HR and workforce management API for payroll, organization, personnel, time management, and related operations.

    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 datetime import date
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from openapi_client.models.city_response import CityResponse
from openapi_client.models.country_response import CountryResponse
from openapi_client.models.employee_full_response import EmployeeFullResponse
from openapi_client.models.religion_response import ReligionResponse
from typing import Optional, Set
from typing_extensions import Self

class EmployeeDetailResponse(BaseModel):
    """
    EmployeeDetailResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    marital_status: Optional[StrictStr] = Field(default=None, alias="maritalStatus")
    religion: Optional[ReligionResponse] = None
    foreign_labour: Optional[StrictBool] = Field(default=None, alias="foreignLabour")
    citizenship: Optional[CountryResponse] = None
    name: Optional[StrictStr] = None
    date_of_birth: Optional[date] = Field(default=None, description="YYYY-MM-DD", alias="dateOfBirth")
    place_of_birth: Optional[CityResponse] = Field(default=None, alias="placeOfBirth")
    gender: Optional[StrictStr] = None
    blood_type: Optional[StrictStr] = Field(default=None, alias="bloodType")
    effective_date: Optional[date] = Field(default=None, description="YYYY-MM-DD", alias="effectiveDate")
    created_by: Optional[StrictStr] = Field(default=None, alias="createdBy")
    created_date: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="createdDate")
    updated_by: Optional[StrictStr] = Field(default=None, alias="updatedBy")
    updated_date: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="updatedDate")
    employee: Optional[EmployeeFullResponse] = None
    __properties: ClassVar[List[str]] = ["id", "maritalStatus", "religion", "foreignLabour", "citizenship", "name", "dateOfBirth", "placeOfBirth", "gender", "bloodType", "effectiveDate", "createdBy", "createdDate", "updatedBy", "updatedDate", "employee"]

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

        if value not in set(['SINGLE', 'MARRIED', 'WIDOW', 'WIDOWER']):
            raise ValueError("must be one of enum values ('SINGLE', 'MARRIED', 'WIDOW', 'WIDOWER')")
        return value

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

        if value not in set(['MALE', 'FEMALE']):
            raise ValueError("must be one of enum values ('MALE', 'FEMALE')")
        return value

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

        if value not in set(['A', 'B', 'O', 'AB']):
            raise ValueError("must be one of enum values ('A', 'B', 'O', 'AB')")
        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 EmployeeDetailResponse 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 religion
        if self.religion:
            _dict['religion'] = self.religion.to_dict()
        # override the default output from pydantic by calling `to_dict()` of citizenship
        if self.citizenship:
            _dict['citizenship'] = self.citizenship.to_dict()
        # override the default output from pydantic by calling `to_dict()` of place_of_birth
        if self.place_of_birth:
            _dict['placeOfBirth'] = self.place_of_birth.to_dict()
        # override the default output from pydantic by calling `to_dict()` of employee
        if self.employee:
            _dict['employee'] = self.employee.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of EmployeeDetailResponse 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"),
            "maritalStatus": obj.get("maritalStatus"),
            "religion": ReligionResponse.from_dict(obj["religion"]) if obj.get("religion") is not None else None,
            "foreignLabour": obj.get("foreignLabour"),
            "citizenship": CountryResponse.from_dict(obj["citizenship"]) if obj.get("citizenship") is not None else None,
            "name": obj.get("name"),
            "dateOfBirth": obj.get("dateOfBirth"),
            "placeOfBirth": CityResponse.from_dict(obj["placeOfBirth"]) if obj.get("placeOfBirth") is not None else None,
            "gender": obj.get("gender"),
            "bloodType": obj.get("bloodType"),
            "effectiveDate": obj.get("effectiveDate"),
            "createdBy": obj.get("createdBy"),
            "createdDate": obj.get("createdDate"),
            "updatedBy": obj.get("updatedBy"),
            "updatedDate": obj.get("updatedDate"),
            "employee": EmployeeFullResponse.from_dict(obj["employee"]) if obj.get("employee") is not None else None
        })
        return _obj


