# coding: utf-8

"""
    Slack Web API

    One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.

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

class ChatPostMessageRequest(BaseModel):
    """
    ChatPostMessageRequest
    """ # noqa: E501
    as_user: Optional[StrictStr] = Field(default=None, description="Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See [authorship](#authorship) below.")
    attachments: Optional[StrictStr] = Field(default=None, description="A JSON-based array of structured attachments, presented as a URL-encoded string.")
    blocks: Optional[StrictStr] = Field(default=None, description="A JSON-based array of structured blocks, presented as a URL-encoded string.")
    channel: StrictStr = Field(description="Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See [below](#channels) for more details.")
    icon_emoji: Optional[StrictStr] = Field(default=None, description="Emoji to use as the icon for this message. Overrides `icon_url`. Must be used in conjunction with `as_user` set to `false`, otherwise ignored. See [authorship](#authorship) below.")
    icon_url: Optional[StrictStr] = Field(default=None, description="URL to an image to use as the icon for this message. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below.")
    link_names: Optional[StrictBool] = Field(default=None, description="Find and link channel names and usernames.")
    mrkdwn: Optional[StrictBool] = Field(default=None, description="Disable Slack markup parsing by setting to `false`. Enabled by default.")
    parse: Optional[StrictStr] = Field(default=None, description="Change how messages are treated. Defaults to `none`. See [below](#formatting).")
    reply_broadcast: Optional[StrictBool] = Field(default=None, description="Used in conjunction with `thread_ts` and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to `false`.")
    text: Optional[StrictStr] = Field(default=None, description="How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail.")
    thread_ts: Optional[StrictStr] = Field(default=None, description="Provide another message's `ts` value to make this message a reply. Avoid using a reply's `ts` value; use its parent instead.")
    unfurl_links: Optional[StrictBool] = Field(default=None, description="Pass true to enable unfurling of primarily text-based content.")
    unfurl_media: Optional[StrictBool] = Field(default=None, description="Pass false to disable unfurling of media content.")
    username: Optional[StrictStr] = Field(default=None, description="Set your bot's user name. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below.")
    __properties: ClassVar[List[str]] = ["as_user", "attachments", "blocks", "channel", "icon_emoji", "icon_url", "link_names", "mrkdwn", "parse", "reply_broadcast", "text", "thread_ts", "unfurl_links", "unfurl_media", "username"]

    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 ChatPostMessageRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "as_user": obj.get("as_user"),
            "attachments": obj.get("attachments"),
            "blocks": obj.get("blocks"),
            "channel": obj.get("channel"),
            "icon_emoji": obj.get("icon_emoji"),
            "icon_url": obj.get("icon_url"),
            "link_names": obj.get("link_names"),
            "mrkdwn": obj.get("mrkdwn"),
            "parse": obj.get("parse"),
            "reply_broadcast": obj.get("reply_broadcast"),
            "text": obj.get("text"),
            "thread_ts": obj.get("thread_ts"),
            "unfurl_links": obj.get("unfurl_links"),
            "unfurl_media": obj.get("unfurl_media"),
            "username": obj.get("username")
        })
        return _obj


