# 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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.id_code_name_response import IdCodeNameResponse
from openapi_client.models.id_response import IdResponse
from openapi_client.models.payroll_process_snapshot_bank_account_configuration_response import PayrollProcessSnapshotBankAccountConfigurationResponse
from openapi_client.models.payroll_process_snapshot_employment_status_response import PayrollProcessSnapshotEmploymentStatusResponse
from openapi_client.models.payroll_process_snapshot_workflow_activity_response import PayrollProcessSnapshotWorkflowActivityResponse
from typing import Optional, Set
from typing_extensions import Self

class PayrollProcessSnapshotResponse(BaseModel):
    """
    PayrollProcessSnapshotResponse
    """ # noqa: E501
    employee_id: Optional[StrictStr] = Field(default=None, alias="employeeId")
    effective_date: Optional[date] = Field(default=None, alias="effectiveDate")
    termination_date: Optional[date] = Field(default=None, alias="terminationDate")
    employment_status: Optional[PayrollProcessSnapshotEmploymentStatusResponse] = Field(default=None, alias="employmentStatus")
    kpp: Optional[IdResponse] = None
    paygroup: Optional[IdCodeNameResponse] = None
    payroll_sequence_number: Optional[StrictInt] = Field(default=None, alias="payrollSequenceNumber")
    previous_payroll_sequence_number: Optional[StrictInt] = Field(default=None, alias="previousPayrollSequenceNumber")
    payment_item_group: Optional[IdResponse] = Field(default=None, alias="paymentItemGroup")
    bank_account_configuration: Optional[PayrollProcessSnapshotBankAccountConfigurationResponse] = Field(default=None, alias="bankAccountConfiguration")
    workflow_activities: Optional[List[PayrollProcessSnapshotWorkflowActivityResponse]] = Field(default=None, alias="workflowActivities")
    __properties: ClassVar[List[str]] = ["employeeId", "effectiveDate", "terminationDate", "employmentStatus", "kpp", "paygroup", "payrollSequenceNumber", "previousPayrollSequenceNumber", "paymentItemGroup", "bankAccountConfiguration", "workflowActivities"]

    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 PayrollProcessSnapshotResponse 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 employment_status
        if self.employment_status:
            _dict['employmentStatus'] = self.employment_status.to_dict()
        # override the default output from pydantic by calling `to_dict()` of kpp
        if self.kpp:
            _dict['kpp'] = self.kpp.to_dict()
        # override the default output from pydantic by calling `to_dict()` of paygroup
        if self.paygroup:
            _dict['paygroup'] = self.paygroup.to_dict()
        # override the default output from pydantic by calling `to_dict()` of payment_item_group
        if self.payment_item_group:
            _dict['paymentItemGroup'] = self.payment_item_group.to_dict()
        # override the default output from pydantic by calling `to_dict()` of bank_account_configuration
        if self.bank_account_configuration:
            _dict['bankAccountConfiguration'] = self.bank_account_configuration.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in workflow_activities (list)
        _items = []
        if self.workflow_activities:
            for _item_workflow_activities in self.workflow_activities:
                if _item_workflow_activities:
                    _items.append(_item_workflow_activities.to_dict())
            _dict['workflowActivities'] = _items
        # set to None if termination_date (nullable) is None
        # and model_fields_set contains the field
        if self.termination_date is None and "termination_date" in self.model_fields_set:
            _dict['terminationDate'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "employeeId": obj.get("employeeId"),
            "effectiveDate": obj.get("effectiveDate"),
            "terminationDate": obj.get("terminationDate"),
            "employmentStatus": PayrollProcessSnapshotEmploymentStatusResponse.from_dict(obj["employmentStatus"]) if obj.get("employmentStatus") is not None else None,
            "kpp": IdResponse.from_dict(obj["kpp"]) if obj.get("kpp") is not None else None,
            "paygroup": IdCodeNameResponse.from_dict(obj["paygroup"]) if obj.get("paygroup") is not None else None,
            "payrollSequenceNumber": obj.get("payrollSequenceNumber"),
            "previousPayrollSequenceNumber": obj.get("previousPayrollSequenceNumber"),
            "paymentItemGroup": IdResponse.from_dict(obj["paymentItemGroup"]) if obj.get("paymentItemGroup") is not None else None,
            "bankAccountConfiguration": PayrollProcessSnapshotBankAccountConfigurationResponse.from_dict(obj["bankAccountConfiguration"]) if obj.get("bankAccountConfiguration") is not None else None,
            "workflowActivities": [PayrollProcessSnapshotWorkflowActivityResponse.from_dict(_item) for _item in obj["workflowActivities"]] if obj.get("workflowActivities") is not None else None
        })
        return _obj


