# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from openapi_client.models.calculation_scenario_component import CalculationScenarioComponent
from openapi_client.models.calculation_scenario_previous_job_component import CalculationScenarioPreviousJobComponent
from typing import Optional, Set
from typing_extensions import Self

class AnnualTaxCalculationSimulatorRequest(BaseModel):
    """
    AnnualTaxCalculationSimulatorRequest
    """ # noqa: E501
    tax_method: StrictStr = Field(alias="taxMethod")
    ptkp_category: StrictStr = Field(alias="ptkpCategory")
    tax_object: StrictStr = Field(alias="taxObject")
    start_month: Annotated[int, Field(le=12, strict=True, ge=1)] = Field(alias="startMonth")
    components: Annotated[List[CalculationScenarioComponent], Field(min_length=1, max_length=12)] = Field(description="List of monthly income components. The last component is the tax end month. For example, if startMonth is 1 and there are 6 components, then endMonth is 6.")
    previous_job_component: Optional[CalculationScenarioPreviousJobComponent] = Field(default=None, alias="previousJobComponent")
    __properties: ClassVar[List[str]] = ["taxMethod", "ptkpCategory", "taxObject", "startMonth", "components", "previousJobComponent"]

    @field_validator('tax_method')
    def tax_method_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['GROSS', 'GROSS_UP', 'NETTO', 'MIX']):
            raise ValueError("must be one of enum values ('GROSS', 'GROSS_UP', 'NETTO', 'MIX')")
        return value

    @field_validator('tax_object')
    def tax_object_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['PERMANENT', 'TEMPORARY', 'MULTI_LEVEL_DISTRIBUTOR', 'INSURANCE_AGENT', 'MERCHANT_GOODS', 'EXPERT_CONTINUOUS', 'EXPERT_NON_CONTINUOUS', 'CONTINUOUS', 'NON_CONTINUOUS', 'COMMISSIONER', 'FORMER_EMPLOYEE', 'EVENT_PARTICIPANT', 'EXPATRIATE', 'EXPERT', 'MEETING_PARTICIPANT', 'COMMITTEE_PARTICIPANT', 'EDUCATION_PARTICIPANT', 'OTHER_PARTICIPANT', 'ADVISOR_LECTURER', 'AUTHOR_RESEARCHER', 'SERVICE_PROVIDER', 'ADVERTISING_AGENT', 'PROJECT_MANAGER', 'INTERMEDIARY', 'ARTIST', 'ATHLETE', 'TEMPORARY_MONTHLY', 'COMPETITION_PARTICIPANT']):
            raise ValueError("must be one of enum values ('PERMANENT', 'TEMPORARY', 'MULTI_LEVEL_DISTRIBUTOR', 'INSURANCE_AGENT', 'MERCHANT_GOODS', 'EXPERT_CONTINUOUS', 'EXPERT_NON_CONTINUOUS', 'CONTINUOUS', 'NON_CONTINUOUS', 'COMMISSIONER', 'FORMER_EMPLOYEE', 'EVENT_PARTICIPANT', 'EXPATRIATE', 'EXPERT', 'MEETING_PARTICIPANT', 'COMMITTEE_PARTICIPANT', 'EDUCATION_PARTICIPANT', 'OTHER_PARTICIPANT', 'ADVISOR_LECTURER', 'AUTHOR_RESEARCHER', 'SERVICE_PROVIDER', 'ADVERTISING_AGENT', 'PROJECT_MANAGER', 'INTERMEDIARY', 'ARTIST', 'ATHLETE', 'TEMPORARY_MONTHLY', 'COMPETITION_PARTICIPANT')")
        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 AnnualTaxCalculationSimulatorRequest 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 each item in components (list)
        _items = []
        if self.components:
            for _item_components in self.components:
                if _item_components:
                    _items.append(_item_components.to_dict())
            _dict['components'] = _items
        # override the default output from pydantic by calling `to_dict()` of previous_job_component
        if self.previous_job_component:
            _dict['previousJobComponent'] = self.previous_job_component.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "taxMethod": obj.get("taxMethod"),
            "ptkpCategory": obj.get("ptkpCategory"),
            "taxObject": obj.get("taxObject"),
            "startMonth": obj.get("startMonth"),
            "components": [CalculationScenarioComponent.from_dict(_item) for _item in obj["components"]] if obj.get("components") is not None else None,
            "previousJobComponent": CalculationScenarioPreviousJobComponent.from_dict(obj["previousJobComponent"]) if obj.get("previousJobComponent") is not None else None
        })
        return _obj


