# 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.employee_simple_response import EmployeeSimpleResponse
from typing import Optional, Set
from typing_extensions import Self

class LeaveBalanceItemResponse(BaseModel):
    """
    LeaveBalanceItemResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    year: Optional[Union[StrictFloat, StrictInt]] = None
    accrual_frequency_type: Optional[StrictStr] = Field(default=None, alias="accrualFrequencyType")
    monthly_accrual_include_bonus: Optional[StrictBool] = Field(default=None, alias="monthlyAccrualIncludeBonus")
    given_date: Optional[StrictStr] = Field(default=None, alias="givenDate")
    start_date: Optional[StrictStr] = Field(default=None, alias="startDate")
    end_date: Optional[StrictStr] = Field(default=None, alias="endDate")
    expected_balance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="expectedBalance")
    balance: Optional[Union[StrictFloat, StrictInt]] = None
    bonus: Optional[Union[StrictFloat, StrictInt]] = None
    debt: Optional[Union[StrictFloat, StrictInt]] = None
    extended: Optional[StrictBool] = None
    maximum_extended_duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="maximumExtendedDuration")
    maximum_extended_balance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="maximumExtendedBalance")
    extended_balance_include_bonus: Optional[StrictBool] = Field(default=None, alias="extendedBalanceIncludeBonus")
    total_balance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalBalance")
    used_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="usedLeave")
    active: Optional[StrictBool] = None
    employee: Optional[EmployeeSimpleResponse] = None
    approved_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="approvedLeave")
    pending_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="pendingLeave")
    collective_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="collectiveLeave")
    remaining: Optional[Union[StrictFloat, StrictInt]] = None
    extended_date: Optional[StrictStr] = Field(default=None, alias="extendedDate")
    extended_balance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedBalance")
    extended_used_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedUsedLeave")
    extended_collective_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedCollectiveLeave")
    extended_available: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedAvailable")
    extended_remaining: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedRemaining")
    extended_approved_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedApprovedLeave")
    extended_pending_leave: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="extendedPendingLeave")
    __properties: ClassVar[List[str]] = ["id", "year", "accrualFrequencyType", "monthlyAccrualIncludeBonus", "givenDate", "startDate", "endDate", "expectedBalance", "balance", "bonus", "debt", "extended", "maximumExtendedDuration", "maximumExtendedBalance", "extendedBalanceIncludeBonus", "totalBalance", "usedLeave", "active", "employee", "approvedLeave", "pendingLeave", "collectiveLeave", "remaining", "extendedDate", "extendedBalance", "extendedUsedLeave", "extendedCollectiveLeave", "extendedAvailable", "extendedRemaining", "extendedApprovedLeave", "extendedPendingLeave"]

    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 LeaveBalanceItemResponse 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 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 LeaveBalanceItemResponse 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"),
            "year": obj.get("year"),
            "accrualFrequencyType": obj.get("accrualFrequencyType"),
            "monthlyAccrualIncludeBonus": obj.get("monthlyAccrualIncludeBonus"),
            "givenDate": obj.get("givenDate"),
            "startDate": obj.get("startDate"),
            "endDate": obj.get("endDate"),
            "expectedBalance": obj.get("expectedBalance"),
            "balance": obj.get("balance"),
            "bonus": obj.get("bonus"),
            "debt": obj.get("debt"),
            "extended": obj.get("extended"),
            "maximumExtendedDuration": obj.get("maximumExtendedDuration"),
            "maximumExtendedBalance": obj.get("maximumExtendedBalance"),
            "extendedBalanceIncludeBonus": obj.get("extendedBalanceIncludeBonus"),
            "totalBalance": obj.get("totalBalance"),
            "usedLeave": obj.get("usedLeave"),
            "active": obj.get("active"),
            "employee": EmployeeSimpleResponse.from_dict(obj["employee"]) if obj.get("employee") is not None else None,
            "approvedLeave": obj.get("approvedLeave"),
            "pendingLeave": obj.get("pendingLeave"),
            "collectiveLeave": obj.get("collectiveLeave"),
            "remaining": obj.get("remaining"),
            "extendedDate": obj.get("extendedDate"),
            "extendedBalance": obj.get("extendedBalance"),
            "extendedUsedLeave": obj.get("extendedUsedLeave"),
            "extendedCollectiveLeave": obj.get("extendedCollectiveLeave"),
            "extendedAvailable": obj.get("extendedAvailable"),
            "extendedRemaining": obj.get("extendedRemaining"),
            "extendedApprovedLeave": obj.get("extendedApprovedLeave"),
            "extendedPendingLeave": obj.get("extendedPendingLeave")
        })
        return _obj


