# 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 datetime import date
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, 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 EmployeeRequest(BaseModel):
    """
    EmployeeRequest
    """ # noqa: E501
    name: Annotated[str, Field(min_length=1, strict=True, max_length=255)]
    username: Optional[Annotated[str, Field(strict=True, max_length=255)]] = None
    email: Optional[Annotated[str, Field(strict=True, max_length=255)]] = None
    join_date: date = Field(description="YYYY-MM-DD", alias="joinDate")
    start_date: date = Field(description="YYYY-MM-DD", alias="startDate")
    contract_start: Optional[date] = Field(default=None, description="YYYY-MM-DD", alias="contractStart")
    contract_end: Optional[date] = Field(default=None, description="YYYY-MM-DD", alias="contractEnd")
    date_of_birth: date = Field(description="YYYY-MM-DD", alias="dateOfBirth")
    employment_status_number: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, alias="employmentStatusNumber")
    employment_type_id: StrictStr = Field(alias="employmentTypeId")
    foreign_labour: Optional[StrictBool] = Field(default=False, alias="foreignLabour")
    gender: StrictStr
    identification_number: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, alias="identificationNumber")
    identity_card_expired_date: Optional[date] = Field(default=None, description="YYYY-MM-DD", alias="identityCardExpiredDate")
    identity_card_number: Annotated[str, Field(min_length=1, strict=True, max_length=255)] = Field(alias="identityCardNumber")
    job_level_id: StrictStr = Field(alias="jobLevelId")
    job_title_id: StrictStr = Field(alias="jobTitleId")
    location_id: StrictStr = Field(alias="locationId")
    marital_status: StrictStr = Field(alias="maritalStatus")
    organization_id: StrictStr = Field(alias="organizationId")
    place_of_birth_id: Optional[StrictStr] = Field(default=None, description="City", alias="placeOfBirthId")
    point_of_hire_id: StrictStr = Field(description="Location", alias="pointOfHireId")
    religion_id: StrictStr = Field(alias="religionId")
    citizenship_id: StrictStr = Field(description="Country", alias="citizenshipId")
    position_id: Optional[StrictStr] = Field(default=None, alias="positionId")
    sub_location_id: Optional[StrictStr] = Field(default=None, alias="subLocationId")
    operational_group_id: Optional[StrictStr] = Field(default=None, alias="operationalGroupId")
    work_email: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, alias="workEmail")
    cost_center_id: Optional[StrictStr] = Field(default=None, alias="costCenterId")
    __properties: ClassVar[List[str]] = ["name", "username", "email", "joinDate", "startDate", "contractStart", "contractEnd", "dateOfBirth", "employmentStatusNumber", "employmentTypeId", "foreignLabour", "gender", "identificationNumber", "identityCardExpiredDate", "identityCardNumber", "jobLevelId", "jobTitleId", "locationId", "maritalStatus", "organizationId", "placeOfBirthId", "pointOfHireId", "religionId", "citizenshipId", "positionId", "subLocationId", "operationalGroupId", "workEmail", "costCenterId"]

    @field_validator('gender')
    def gender_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['MALE', 'FEMALE']):
            raise ValueError("must be one of enum values ('MALE', 'FEMALE')")
        return value

    @field_validator('marital_status')
    def marital_status_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['SINGLE', 'MARRIED', 'WIDOW', 'WIDOWER']):
            raise ValueError("must be one of enum values ('SINGLE', 'MARRIED', 'WIDOW', 'WIDOWER')")
        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 EmployeeRequest 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 username (nullable) is None
        # and model_fields_set contains the field
        if self.username is None and "username" in self.model_fields_set:
            _dict['username'] = None

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "username": obj.get("username"),
            "email": obj.get("email"),
            "joinDate": obj.get("joinDate"),
            "startDate": obj.get("startDate"),
            "contractStart": obj.get("contractStart"),
            "contractEnd": obj.get("contractEnd"),
            "dateOfBirth": obj.get("dateOfBirth"),
            "employmentStatusNumber": obj.get("employmentStatusNumber"),
            "employmentTypeId": obj.get("employmentTypeId"),
            "foreignLabour": obj.get("foreignLabour") if obj.get("foreignLabour") is not None else False,
            "gender": obj.get("gender"),
            "identificationNumber": obj.get("identificationNumber"),
            "identityCardExpiredDate": obj.get("identityCardExpiredDate"),
            "identityCardNumber": obj.get("identityCardNumber"),
            "jobLevelId": obj.get("jobLevelId"),
            "jobTitleId": obj.get("jobTitleId"),
            "locationId": obj.get("locationId"),
            "maritalStatus": obj.get("maritalStatus"),
            "organizationId": obj.get("organizationId"),
            "placeOfBirthId": obj.get("placeOfBirthId"),
            "pointOfHireId": obj.get("pointOfHireId"),
            "religionId": obj.get("religionId"),
            "citizenshipId": obj.get("citizenshipId"),
            "positionId": obj.get("positionId"),
            "subLocationId": obj.get("subLocationId"),
            "operationalGroupId": obj.get("operationalGroupId"),
            "workEmail": obj.get("workEmail"),
            "costCenterId": obj.get("costCenterId")
        })
        return _obj


