o
    VhfC                     @   s   d dl mZmZ d dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZ G dd dZG dd deed	ZG d
d dZG dd deZdS )    )ABCMetaabstractmethod)wraps)CallableIterableSetUnionAnyTuple)SlackObjectFormationErrorc                   @   s   e Zd ZdZdd ZdS )
BaseObjectz3The base class for all model objects in this modulec                 C   s   d| j j dS )N<slack_sdk.>)	__class____name__self r   c/var/www/html/status_management/venv/lib/python3.10/site-packages/slack_sdk/models/basic_objects.py__str__   s   zBaseObject.__str__N)r   
__module____qualname____doc__r   r   r   r   r   r      s    r   c                   @   sj   e Zd ZdZeedee fddZdddZ	de
fdd	Zde
fd
dZdd ZdedefddZdS )
JsonObjectz2The base class for JSON serializable class objectsreturnc                 C   s   t  S )zOProvide a set of attributes of this object that will make up its JSON structure)setr   r   r   r   
attributes   s   zJsonObject.attributesNc                 C   s@   dd t | D D ]}t| |d}t|rt|dr|  q	dS )zY
        Raises:
          SlackObjectFormationError if the object was not valid
        c                 s   s    | ]
}| d s|V  qdS )__N)
startswith).0funcr   r   r   	<genexpr>   s    z+JsonObject.validate_json.<locals>.<genexpr>N	validator)dirgetattrcallablehasattr)r   	attributemethodr   r   r   validate_json   s   zJsonObject.validate_jsonc                    sZ   dt ttttf dt tttf ffdddtdtfdd  fdd	tj	D S )
zw
        Construct a dictionary out of non-null keys (from attributes property)
        present on this object
        valuer   c                    sV   t | ttfr fdd| D S t| dd }|r)t|r) fdd|   D S | S )Nc                    s   g | ]} |qS r   r   )r   vto_dict_compatibler   r   
<listcomp>*   s    zRJsonObject.get_non_null_attributes.<locals>.to_dict_compatible.<locals>.<listcomp>to_dictc                    s   i | ]	\}}| |qS r   r   )r   kr+   r,   r   r   
<dictcomp>.   s    zRJsonObject.get_non_null_attributes.<locals>.to_dict_compatible.<locals>.<dictcomp>)
isinstancelistr
   r$   r%   r/   items)r*   r/   r,   r   r   r-   (   s   z>JsonObject.get_non_null_attributes.<locals>.to_dict_compatiblekeyc                 S   s@   t | |d }|d u rdS t |dd d u}|rt|dkS |d uS )NF__len__r   )r$   len)r   r5   r*   has_lenr   r   r   is_not_empty2   s   z8JsonObject.get_non_null_attributes.<locals>.is_not_emptyc                    s(   i | ]} |r|t |d qS N)r$   )r   r5   r9   r   r-   r   r   r1   <   s
    
z6JsonObject.get_non_null_attributes.<locals>.<dictcomp>)
r   dictr3   objectr
   r	   strboolsortedr   r   r   r;   r   get_non_null_attributes"   s
   ,

z"JsonObject.get_non_null_attributesc                 G   s   |    |  S )a  
        Extract this object as a JSON-compatible, Slack-API-valid dictionary

        Args:
          *args: Any specific formatting args (rare; generally not required)

        Raises:
          SlackObjectFormationError if the object was not valid
        )r)   rA   )r   argsr   r   r   r/   @   s   
zJsonObject.to_dictc                 C   s*   |   }|rd| jj d| dS |  S )Nr   z: r   )rA   r   r   r   )r   
dict_valuer   r   r   __repr__M   s   zJsonObject.__repr__otherc                 C   s   t |tsdS |  | kS )NF)r2   r   r/   )r   rE   r   r   r   __eq__T   s   
zJsonObject.__eq__)r   N)r   r   r   r   propertyr   r   r>   r   r)   r<   rA   r/   rD   r	   r?   rF   r   r   r   r   r      s    

r   )	metaclassc                   @   s0   e Zd ZdefddZdeded fddZd	S )
JsonValidatormessagec                 C   s
   || _ dS )z
        Decorate a method on a class to mark it as a JSON validator. Validation
            functions should return true if valid, false if not.

        Args:
            message: Message to be attached to the thrown SlackObjectFormationError
        N)rJ   )r   rJ   r   r   r   __init__[   s   
zJsonValidator.__init__r    r   ).Nc                    s    t   fdd}d|_|S )Nc                     s    | i |st jd S r:   )r   rJ   )rB   kwargsr    r   r   r   	wrapped_ff   s   
z)JsonValidator.__call__.<locals>.wrapped_fT)r   r"   )r   r    rN   r   rM   r   __call__e   s   zJsonValidator.__call__N)r   r   r   r>   rK   r   rO   r   r   r   r   rI   Z   s    
rI   c                       s*   e Zd Zdedee f fddZ  ZS )EnumValidatorr'   enumc                    s    t  | dd|  d S )Nz0 attribute must be one of the following values: z, )superrK   join)r   r'   rQ   r   r   r   rK   p   s    zEnumValidator.__init__)r   r   r   r>   r   rK   __classcell__r   r   rT   r   rP   o   s    "rP   N)abcr   r   	functoolsr   typingr   r   r   r   r	   r
   slack_sdk.errorsr   r   r   rI   rP   r   r   r   r   <module>   s     K