# coding: utf-8

"""
    (v2.0) Dynamics 365 Business Central

    (v2.0) Business Central Standard APIs

    The version of the OpenAPI document: 2.0.0
    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 datetime
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from pybusinesscentral.model.default_dimensions import DefaultDimensions
from pybusinesscentral.model.picture import Picture
from pybusinesscentral.model.postaladdresstype import Postaladdresstype
from pybusinesscentral.model.time_registration_entry import TimeRegistrationEntry
from typing import Optional, Set
from typing_extensions import Self

class Employee(BaseModel):
    """
    Employee
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="(v1.0) The id property for the Dynamics 365 Business Central employee entity")
    number: Optional[Annotated[str, Field(strict=True, max_length=20)]] = Field(default=None, description="(v1.0) The number property for the Dynamics 365 Business Central employee entity")
    display_name: Optional[StrictStr] = Field(default=None, description="(v1.0) The displayName property for the Dynamics 365 Business Central employee entity", alias="displayName")
    given_name: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The givenName property for the Dynamics 365 Business Central employee entity", alias="givenName")
    middle_name: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The middleName property for the Dynamics 365 Business Central employee entity", alias="middleName")
    surname: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The surname property for the Dynamics 365 Business Central employee entity")
    job_title: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The jobTitle property for the Dynamics 365 Business Central employee entity", alias="jobTitle")
    address: Optional[Postaladdresstype] = None
    phone_number: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The phoneNumber property for the Dynamics 365 Business Central employee entity", alias="phoneNumber")
    mobile_phone: Optional[Annotated[str, Field(strict=True, max_length=30)]] = Field(default=None, description="(v1.0) The mobilePhone property for the Dynamics 365 Business Central employee entity", alias="mobilePhone")
    email: Optional[Annotated[str, Field(strict=True, max_length=80)]] = Field(default=None, description="(v1.0) The email property for the Dynamics 365 Business Central employee entity")
    personal_email: Optional[Annotated[str, Field(strict=True, max_length=80)]] = Field(default=None, description="(v1.0) The personalEmail property for the Dynamics 365 Business Central employee entity", alias="personalEmail")
    employment_date: Optional[datetime] = Field(default=None, description="(v1.0) The employmentDate property for the Dynamics 365 Business Central employee entity", alias="employmentDate")
    termination_date: Optional[datetime] = Field(default=None, description="(v1.0) The terminationDate property for the Dynamics 365 Business Central employee entity", alias="terminationDate")
    status: Optional[StrictStr] = Field(default=None, description="(v1.0) The status property for the Dynamics 365 Business Central employee entity")
    birth_date: Optional[datetime] = Field(default=None, description="(v1.0) The birthDate property for the Dynamics 365 Business Central employee entity", alias="birthDate")
    statistics_group_code: Optional[Annotated[str, Field(strict=True, max_length=10)]] = Field(default=None, description="(v1.0) The statisticsGroupCode property for the Dynamics 365 Business Central employee entity", alias="statisticsGroupCode")
    last_modified_date_time: Optional[datetime] = Field(default=None, description="(v1.0) The lastModifiedDateTime property for the Dynamics 365 Business Central employee entity", alias="lastModifiedDateTime")
    picture: Optional[List[Picture]] = None
    default_dimensions: Optional[List[DefaultDimensions]] = Field(default=None, alias="defaultDimensions")
    time_registration_entries: Optional[List[TimeRegistrationEntry]] = Field(default=None, alias="timeRegistrationEntries")
    __properties: ClassVar[List[str]] = ["id", "number", "displayName", "givenName", "middleName", "surname", "jobTitle", "address", "phoneNumber", "mobilePhone", "email", "personalEmail", "employmentDate", "terminationDate", "status", "birthDate", "statisticsGroupCode", "lastModifiedDateTime", "picture", "defaultDimensions", "timeRegistrationEntries"]

    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 Employee 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 address
        if self.address:
            _dict['address'] = self.address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in picture (list)
        _items = []
        if self.picture:
            for _item_picture in self.picture:
                if _item_picture:
                    _items.append(_item_picture.to_dict())
            _dict['picture'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in default_dimensions (list)
        _items = []
        if self.default_dimensions:
            for _item_default_dimensions in self.default_dimensions:
                if _item_default_dimensions:
                    _items.append(_item_default_dimensions.to_dict())
            _dict['defaultDimensions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in time_registration_entries (list)
        _items = []
        if self.time_registration_entries:
            for _item_time_registration_entries in self.time_registration_entries:
                if _item_time_registration_entries:
                    _items.append(_item_time_registration_entries.to_dict())
            _dict['timeRegistrationEntries'] = _items
        # set to None if number (nullable) is None
        # and model_fields_set contains the field
        if self.number is None and "number" in self.model_fields_set:
            _dict['number'] = None

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

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

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

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

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

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

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

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

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

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

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

        # 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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of Employee 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"),
            "number": obj.get("number"),
            "displayName": obj.get("displayName"),
            "givenName": obj.get("givenName"),
            "middleName": obj.get("middleName"),
            "surname": obj.get("surname"),
            "jobTitle": obj.get("jobTitle"),
            "address": Postaladdresstype.from_dict(obj["address"]) if obj.get("address") is not None else None,
            "phoneNumber": obj.get("phoneNumber"),
            "mobilePhone": obj.get("mobilePhone"),
            "email": obj.get("email"),
            "personalEmail": obj.get("personalEmail"),
            "employmentDate": obj.get("employmentDate"),
            "terminationDate": obj.get("terminationDate"),
            "status": obj.get("status"),
            "birthDate": obj.get("birthDate"),
            "statisticsGroupCode": obj.get("statisticsGroupCode"),
            "lastModifiedDateTime": obj.get("lastModifiedDateTime"),
            "picture": [Picture.from_dict(_item) for _item in obj["picture"]] if obj.get("picture") is not None else None,
            "defaultDimensions": [DefaultDimensions.from_dict(_item) for _item in obj["defaultDimensions"]] if obj.get("defaultDimensions") is not None else None,
            "timeRegistrationEntries": [TimeRegistrationEntry.from_dict(_item) for _item in obj["timeRegistrationEntries"]] if obj.get("timeRegistrationEntries") is not None else None
        })
        return _obj


