
    3fiV                     ^    d dl mZ ddlmZ  G d de      Z G d de      Z G d d	e      Zy
)    )Enum   )ApiComponentc                       e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZed        Zy)CategoryColorpreset0preset1preset2preset3preset4preset5preset6preset7preset8preset9preset10preset11preset12preset13preset14preset15preset16preset17preset18preset19preset20preset21preset22preset23preset24c                     	  | |j                               S # t        $ r Y nw xY w	 | |j                            S # t        $ r t        d      dw xY w)zy
        Gets a color by name or value.
        Raises ValueError if not found whithin the collection of colors.
        z-color is not a valid color from CategoryColorN)
capitalize
ValueErrorupperKeyError)clscolors     K/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/O365/category.pygetzCategoryColor.get!   sd    	u'')** 			Xu{{}%% 	XLMSWW	Xs    	$$; AN)__name__
__module____qualname__REDORANGEBROWNYELLOWGREENTEALOLIVEBLUEPURPLE	CRANBERRYSTEEL	DARKSTEELGRAYDARKGREYBLACKDARKRED
DARKORANGE	DARKBROWN
DARKYELLOW	DARKGREENDARKTEAL	DARKOLIVEDARKBLUE
DARKPURPLEDARKCRANBERRYclassmethodr)        r(   r   r      s    
CFEFEDEDFIEIDHEGJIJIHIHJMX XrH   r   c                   F     e Zd ZddiZddd fd
Zd Zd Zd Zd	 Z xZ	S )
Categoryupdate/outlook/masterCategories/{id}Nparentconc                   |r|rt        d      |r|j                  n|| _        |j                  dd      xs |rt        |dd      nd}t        |   |r|j                  n|j                  d      |       |j                  | j                  i       }|j                  d      | _	        |j                  | j                  d            | _        |j                  | j                  d            }|rt        |      | _        yd| _        y)	a  Represents a category by which a user can group Outlook items such as messages and events.
        It can be used in conjunction with Event, Message, Contact and Post.

        :param parent: parent object
        :type parent: Account
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)

        *Need a parent or a connection but not bothmain_resourceNprotocolrS   rR   iddisplayNamer'   )r#   rO   popgetattrsuper__init__rS   r)   _cloud_data_key	object_id_ccnamer   r'   )selfrN   rO   kwargsrR   
cloud_datar'   	__class__s          r(   rZ   zCategory.__init__7   s     cIJJ!'6::S 

?D9 H6<GFOT2$ 	 	(.V__FJJz4J' 	 	) ZZ 4 4b9
 $-NN488M#:;	txx01-2]5)

rH   c                 "    | j                         S )N)__repr__r_   s    r(   __str__zCategory.__str__[   s    }}rH   c                     dj                  | j                  | j                  r| j                  j                        S d       S )Nz{} (color: {}))formatr^   r'   re   s    r(   rd   zCategory.__repr__^   s0    &&tyyTZZ$**//ZZUYZZrH   c                 H   | j                  | j                  j                  d      j                  | j                              }|%t        |t              st        j                  |      }| j                  j                  |d|r|j                  ndi      }|sy|| _
        y)zs
        Updates this Category color
        :param None or str or CategoryColor color: the category color
        rK   rU   Nr'   dataFT)	build_url
_endpointsr)   rh   r\   
isinstancer   rO   patchvaluer'   )r_   r'   urlresponses       r(   update_colorzCategory.update_colora   s    
 nnT__00:AAT^^ATUZ}%E!%%e,E88>>#WUekkPT,U>V
rH   c                     | j                  | j                  j                  d      j                  | j                              }| j
                  j                  |      }t        |      S )z Deletes this Category rK   rj   )rm   rn   r)   rh   r\   rO   deletebool)r_   rr   rs   s      r(   rv   zCategory.deleteq   sM    nnT__00:AAT^^ATU88??3'H~rH   )
r*   r+   r,   rn   rZ   rf   rd   rt   rv   __classcell__rb   s   @r(   rJ   rJ   1   s4     	2J "&4 "=H[ rH   rJ   c                   H     e Zd ZdddZeZddd fd
Zd Zd Zd
d	Z	 xZ
S )
Categoriesz/outlook/masterCategoriesrL   )listr)   NrM   c                    |r|rt        d      |r|j                  n|| _        |j                  dd      xs |rt        |dd      nd}t        |   |r|j                  n|j                  d      |       y)an   Object to retrive categories

        :param parent: parent object
        :type parent: Account
        :param Connection con: connection to use if no parent specified
        :param Protocol protocol: protocol to use if no parent specified
         (kwargs)
        :param str main_resource: use this resource instead of parent resource
         (kwargs)
        rQ   rR   NrS   rT   )r#   rO   rW   rX   rY   rZ   rS   r)   )r_   rN   rO   r`   rR   rb   s        r(   rZ   zCategories.__init__   s{     cIJJ!'6::S 

?D9 H6<GFOT2$ 	 	(.V__FJJz4J' 	 	)rH   c           	      :   | j                  | j                  j                  d            }| j                  j                  |      }|sg S |j	                         }|j                  dg       D cg c]"  } | j
                  dd| i| j                  |i$ c}S c c}w )z Returns a list of categoriesr|   rq   rN   rG   )rm   rn   r)   rO   jsoncategory_constructorr[   )r_   rr   rs   rl   categorys        r(   get_categorieszCategories.get_categories   s    nnT__008988<<$I}} !HHWb1
 &D%%VTVd6J6JH5UV
 	
 
s   .'Bc                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns a category by idr)   rj   NrN   rG   )rm   rn   r)   rh   rO   r   r   r[   )r_   category_idrr   rs   rl   s        r(   get_categoryzCategories.get_category   sv    nnT__007>>+>NO88<<$}}(t((UU9M9Mt8TUUrH   c                    |dk(  rQ| j                         D ch c]  }|j                   }}t        D ch c]  }| }}||z
  }	 |j                         }n'|%t        |t              st        j                  |      }| j                  | j                  j                  d            }| j                  d      |d|r|j                  ndi}| j                  j                  ||      }	|	sy|	j                         } | j                  dd| i| j                  |iS c c}w c c}w # t        $ r |j                         }Y w xY w)	aK  
        Creates a category.
        If the color is not provided it will be choosed from the pool of unused colors.

        :param str name: The name of this outlook category. Must be unique.
        :param str or CategoryColor color: optional color. If not provided will be assigned automatically.
        :return: bool
        autoNr|   rV   r'   rk   rN   rG   )r   r'   r   rW   r%   ro   r)   rm   rn   r]   rq   rO   postr   r   r[   )
r_   r^   r'   r   used_colors
all_colorsavailable_colorsrr   rl   rs   s
             r(   create_categoryzCategories.create_category   s-    F?:>:M:M:OPh8>>PKP-:;E%;J;)K7)(,,.
  E=)I%))%0nnT__0089'wuRVW88==4=0==?(t((YY9M9Mx8XYY) Q;  )"()s   D	D D% %E E)r   )r*   r+   r,   rn   rJ   r   rZ   r   r   r   rx   ry   s   @r(   r{   r{   z   s5     ,/J
 $!%4 )0

VZrH   r{   N)enumr   utilsr   r   rJ   r{   rG   rH   r(   <module>r      s9     (XD (XVF| FRZZ ZZrH   