# 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
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.cost_center_response import CostCenterResponse
from openapi_client.models.job_level_response import JobLevelResponse
from openapi_client.models.job_title_response import JobTitleResponse
from openapi_client.models.location_response import LocationResponse
from openapi_client.models.organization_response import OrganizationResponse
from typing import Optional, Set
from typing_extensions import Self

class PositionResponse(BaseModel):
    """
    PositionResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    code: Optional[StrictStr] = None
    name: Optional[StrictStr] = None
    organization: Optional[OrganizationResponse] = None
    job_title: Optional[JobTitleResponse] = Field(default=None, alias="jobTitle")
    job_level: Optional[JobLevelResponse] = Field(default=None, alias="jobLevel")
    cost_center: Optional[CostCenterResponse] = Field(default=None, alias="costCenter")
    location: Optional[LocationResponse] = None
    assigned: Optional[StrictBool] = None
    effective_date: Optional[StrictStr] = Field(default=None, alias="effectiveDate")
    end_date: Optional[StrictStr] = Field(default=None, alias="endDate")
    __properties: ClassVar[List[str]] = ["id", "code", "name", "organization", "jobTitle", "jobLevel", "costCenter", "location", "assigned", "effectiveDate", "endDate"]

    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 PositionResponse 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 organization
        if self.organization:
            _dict['organization'] = self.organization.to_dict()
        # override the default output from pydantic by calling `to_dict()` of job_title
        if self.job_title:
            _dict['jobTitle'] = self.job_title.to_dict()
        # override the default output from pydantic by calling `to_dict()` of job_level
        if self.job_level:
            _dict['jobLevel'] = self.job_level.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cost_center
        if self.cost_center:
            _dict['costCenter'] = self.cost_center.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location
        if self.location:
            _dict['location'] = self.location.to_dict()
        # set to None if end_date (nullable) is None
        # and model_fields_set contains the field
        if self.end_date is None and "end_date" in self.model_fields_set:
            _dict['endDate'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PositionResponse 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"),
            "code": obj.get("code"),
            "name": obj.get("name"),
            "organization": OrganizationResponse.from_dict(obj["organization"]) if obj.get("organization") is not None else None,
            "jobTitle": JobTitleResponse.from_dict(obj["jobTitle"]) if obj.get("jobTitle") is not None else None,
            "jobLevel": JobLevelResponse.from_dict(obj["jobLevel"]) if obj.get("jobLevel") is not None else None,
            "costCenter": CostCenterResponse.from_dict(obj["costCenter"]) if obj.get("costCenter") is not None else None,
            "location": LocationResponse.from_dict(obj["location"]) if obj.get("location") is not None else None,
            "assigned": obj.get("assigned"),
            "effectiveDate": obj.get("effectiveDate"),
            "endDate": obj.get("endDate")
        })
        return _obj


