# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.termination_reason_response import TerminationReasonResponse
from typing import Optional, Set
from typing_extensions import Self

class TerminationEntryResponse(BaseModel):
    """
    TerminationEntryResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    termination_code: Optional[StrictStr] = Field(default=None, alias="terminationCode")
    effective_date: Optional[StrictStr] = Field(default=None, alias="effectiveDate")
    payroll_method: Optional[StrictStr] = Field(default=None, alias="payrollMethod")
    termination_reason: Optional[TerminationReasonResponse] = Field(default=None, alias="terminationReason")
    bpjs_manpower_end_date: Optional[StrictStr] = Field(default=None, alias="bpjsManpowerEndDate")
    bpjs_healthcare_end_date: Optional[StrictStr] = Field(default=None, alias="bpjsHealthcareEndDate")
    pph21_membership_end_date: Optional[StrictStr] = Field(default=None, alias="pph21MembershipEndDate")
    request_date: Optional[StrictStr] = Field(default=None, alias="requestDate")
    service_period_by: Optional[StrictStr] = Field(default=None, alias="servicePeriodBy")
    rehire: Optional[StrictBool] = None
    approval_status: Optional[StrictStr] = Field(default=None, alias="approvalStatus")
    __properties: ClassVar[List[str]] = ["id", "terminationCode", "effectiveDate", "payrollMethod", "terminationReason", "bpjsManpowerEndDate", "bpjsHealthcareEndDate", "pph21MembershipEndDate", "requestDate", "servicePeriodBy", "rehire", "approvalStatus"]

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

        if value not in set(['APPROVED', 'REJECTED', 'WAITING_FOR_APPROVAL']):
            raise ValueError("must be one of enum values ('APPROVED', 'REJECTED', 'WAITING_FOR_APPROVAL')")
        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 TerminationEntryResponse 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 termination_reason
        if self.termination_reason:
            _dict['terminationReason'] = self.termination_reason.to_dict()
        # set to None if termination_code (nullable) is None
        # and model_fields_set contains the field
        if self.termination_code is None and "termination_code" in self.model_fields_set:
            _dict['terminationCode'] = None

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of TerminationEntryResponse 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"),
            "terminationCode": obj.get("terminationCode"),
            "effectiveDate": obj.get("effectiveDate"),
            "payrollMethod": obj.get("payrollMethod"),
            "terminationReason": TerminationReasonResponse.from_dict(obj["terminationReason"]) if obj.get("terminationReason") is not None else None,
            "bpjsManpowerEndDate": obj.get("bpjsManpowerEndDate"),
            "bpjsHealthcareEndDate": obj.get("bpjsHealthcareEndDate"),
            "pph21MembershipEndDate": obj.get("pph21MembershipEndDate"),
            "requestDate": obj.get("requestDate"),
            "servicePeriodBy": obj.get("servicePeriodBy"),
            "rehire": obj.get("rehire"),
            "approvalStatus": obj.get("approvalStatus")
        })
        return _obj


