# coding: utf-8

"""
    ibl-data-manager

    API for iblai

    The version of the OpenAPI document: 3.54.3-ai-plus
    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
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class TeamsWebhook(BaseModel):
    """
    TeamsWebhook
    """ # noqa: E501
    id: Optional[StrictStr] = None
    type: Optional[StrictStr] = None
    channel_data: Optional[Dict[str, Any]] = Field(default=None, alias="channelData")
    entities: Optional[List[Any]] = None
    text: Optional[StrictStr] = None
    locale: Optional[StrictStr] = None
    text_format: Optional[StrictStr] = Field(default=None, alias="textFormat")
    recipient: Optional[Dict[str, Any]] = None
    conversation: Optional[Dict[str, Any]] = None
    from_: Optional[Dict[str, Any]] = None
    channel_id: Optional[StrictStr] = Field(default=None, alias="channelId")
    service_url: Optional[StrictStr] = Field(default=None, alias="serviceUrl")
    local_timezone: Optional[StrictStr] = Field(default=None, alias="localTimezone")
    local_timestamp: Optional[StrictStr] = Field(default=None, alias="localTimestamp")
    timestamp: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "type", "channelData", "entities", "text", "locale", "textFormat", "recipient", "conversation", "from_", "channelId", "serviceUrl", "localTimezone", "localTimestamp", "timestamp"]

    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 TeamsWebhook 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,
        )
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['id'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of TeamsWebhook 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"),
            "type": obj.get("type"),
            "channelData": obj.get("channelData"),
            "entities": obj.get("entities"),
            "text": obj.get("text"),
            "locale": obj.get("locale"),
            "textFormat": obj.get("textFormat"),
            "recipient": obj.get("recipient"),
            "conversation": obj.get("conversation"),
            "from_": obj.get("from_"),
            "channelId": obj.get("channelId"),
            "serviceUrl": obj.get("serviceUrl"),
            "localTimezone": obj.get("localTimezone"),
            "localTimestamp": obj.get("localTimestamp"),
            "timestamp": obj.get("timestamp")
        })
        return _obj


