# coding: utf-8

"""
    LINE WORKS Talk API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from line_works.openapi.talk.models.email import Email
from line_works.openapi.talk.models.name import Name
from line_works.openapi.talk.models.organization import Organization
from line_works.openapi.talk.models.works_at import WorksAt
from typing import Optional, Set
from typing_extensions import Self

class MyInfo(BaseModel):
    """
    
    """ # noqa: E501
    tenant_id: StrictInt = Field(alias="tenantId")
    domain_id: StrictInt = Field(alias="domainId")
    contact_no: StrictInt = Field(alias="contactNo")
    read_only: StrictBool = Field(alias="readOnly")
    temp_id: StrictBool = Field(alias="tempId")
    name: Name
    i18n_name: StrictStr = Field(alias="i18nName")
    i18n_names: List[Dict[str, Any]] = Field(alias="i18nNames")
    photos: List[Dict[str, Any]]
    organizations: List[Organization]
    emails: List[Email]
    telephones: List[Dict[str, Any]]
    messengers: List[Dict[str, Any]]
    position: StrictStr
    department: StrictStr
    location: Optional[StrictStr]
    important: StrictBool
    executive: StrictBool
    photo_hash: StrictStr = Field(alias="photoHash")
    works_at: WorksAt = Field(alias="worksAt")
    access_limit: StrictBool = Field(alias="accessLimit")
    user_photo_modify: StrictBool = Field(alias="userPhotoModify")
    user_absence_modify: StrictBool = Field(alias="userAbsenceModify")
    organization: StrictStr
    groups: List[Dict[str, Any]]
    works_services: List[StrictStr] = Field(alias="worksServices")
    custom_fields: List[Dict[str, Any]] = Field(alias="customFields")
    profile_statuses: List[Dict[str, Any]] = Field(alias="profileStatuses")
    profile_statuses_v2: List[Dict[str, Any]] = Field(alias="profileStatusesV2")
    instance: StrictInt
    __properties: ClassVar[List[str]] = ["tenantId", "domainId", "contactNo", "readOnly", "tempId", "name", "i18nName", "i18nNames", "photos", "organizations", "emails", "telephones", "messengers", "position", "department", "location", "important", "executive", "photoHash", "worksAt", "accessLimit", "userPhotoModify", "userAbsenceModify", "organization", "groups", "worksServices", "customFields", "profileStatuses", "profileStatusesV2", "instance"]

    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 MyInfo 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 name
        if self.name:
            _dict['name'] = self.name.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in organizations (list)
        _items = []
        if self.organizations:
            for _item_organizations in self.organizations:
                if _item_organizations:
                    _items.append(_item_organizations.to_dict())
            _dict['organizations'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in emails (list)
        _items = []
        if self.emails:
            for _item_emails in self.emails:
                if _item_emails:
                    _items.append(_item_emails.to_dict())
            _dict['emails'] = _items
        # override the default output from pydantic by calling `to_dict()` of works_at
        if self.works_at:
            _dict['worksAt'] = self.works_at.to_dict()
        # set to None if location (nullable) is None
        # and model_fields_set contains the field
        if self.location is None and "location" in self.model_fields_set:
            _dict['location'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "tenantId": obj.get("tenantId"),
            "domainId": obj.get("domainId"),
            "contactNo": obj.get("contactNo"),
            "readOnly": obj.get("readOnly"),
            "tempId": obj.get("tempId"),
            "name": Name.from_dict(obj["name"]) if obj.get("name") is not None else None,
            "i18nName": obj.get("i18nName"),
            "i18nNames": obj.get("i18nNames"),
            "photos": obj.get("photos"),
            "organizations": [Organization.from_dict(_item) for _item in obj["organizations"]] if obj.get("organizations") is not None else None,
            "emails": [Email.from_dict(_item) for _item in obj["emails"]] if obj.get("emails") is not None else None,
            "telephones": obj.get("telephones"),
            "messengers": obj.get("messengers"),
            "position": obj.get("position"),
            "department": obj.get("department"),
            "location": obj.get("location"),
            "important": obj.get("important"),
            "executive": obj.get("executive"),
            "photoHash": obj.get("photoHash"),
            "worksAt": WorksAt.from_dict(obj["worksAt"]) if obj.get("worksAt") is not None else None,
            "accessLimit": obj.get("accessLimit"),
            "userPhotoModify": obj.get("userPhotoModify"),
            "userAbsenceModify": obj.get("userAbsenceModify"),
            "organization": obj.get("organization"),
            "groups": obj.get("groups"),
            "worksServices": obj.get("worksServices"),
            "customFields": obj.get("customFields"),
            "profileStatuses": obj.get("profileStatuses"),
            "profileStatusesV2": obj.get("profileStatusesV2"),
            "instance": obj.get("instance")
        })
        return _obj


