
    3fi`                        d dl Z d dlmZ d dlmZ ddlmZmZmZ  e j                  e
      ZdZdZ G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Zy)!    N)Enum)parse   )NEXT_LINK_KEYWORDApiComponent
Pagination2   c                        e Zd ZdZdZdZdZdZy)AvailabilityValid values for Availability.	AvailableBusyAwayDoNotDisturbN)__name__
__module____qualname____doc__	AVAILABLEBUSYAWAYDONOTDISTURB     H/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/O365/teams.pyr   r      s    (IDD!Lr   r   c                   $    e Zd ZdZdZdZdZdZdZy)ActivityValid values for Activity.r   InACallInAConferenceCallr   
PresentingN)	r   r   r   r   r   INACALLINACONFERENCECALLr   
PRESENTINGr   r   r   r   r      s    $IG+DJr   r   c                   (    e Zd ZdZdZdZdZdZdZdZ	y)	PreferredAvailabilityr   r   r   r   BeRightBackr   OfflineN)
r   r   r   r   r   r   r   BERIGHTBACKr   OFFLINEr   r   r   r&   r&       s#    (ID!LKDGr   r&   c                   (    e Zd ZdZdZdZdZdZdZdZ	y)	PreferredActivityr   r   r   r   r'   r   OffWorkN)
r   r   r   r   r   r   r   r)   r   OFFWORKr   r   r   r,   r,   +   s#    $ID!LKDGr   r,   c                   6     e Zd ZdZddd fd
Zd Zd Z xZS )ConversationMemberz' A Microsoft Teams conversation member Nparentconc                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  | j                        }dj                  ||      }t        | %  |r|j                  n|j                  d      |	       |j                  d
      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        y)aa   A Microsoft Teams conversation member
        :param parent: parent object
        :type parent: Chat
        :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idmain_resourceN/members/{membership_id}membership_id{}{}protocolr<   r7   rolesdisplayNameuserIdemailtenantId)
ValueErrorr3   get_cloud_data_key	object_idpopgetattrformatsuper__init__r<   r>   display_nameuser_idrA   	tenant_idselfr2   r3   kwargs
cloud_datar7   resource_prefix	__class__s          r   rK   zConversationMember.__init__8   s    cIJJ!'6::SZZ 4 4b9
#- 

?D9 H6<GFOT2$ 	4;;.. < *m_E(.V__FJJz4J' 	 	)  ^^G,
&NN=9!~~h/^^G,
#
3r   c                 N    dj                  | j                  | j                        S )NzConversationMember: {} - {})rI   rL   rA   rP   s    r   __repr__zConversationMember.__repr__V   s&    ,33D4E4E48JJ@ 	@r   c                 "    | j                         S NrW   rV   s    r   __str__zConversationMember.__str__Z       }}r   r   r   r   r   rK   rW   r[   __classcell__rT   s   @r   r0   r0   5   s    1!%4 4<@r   r0   c                   6     e Zd ZdZddd fd
Zd Zd Z xZS )ChatMessagez  A Microsoft Teams chat message Nr1   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}|j                  d      | _        | j                  rdj                  | j                        }ndj                  | j                        }d	j                  ||      }t        | )  |r|j                  n|j                  d
      |       |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        | j                  j"                  }|j                  d      }|j                  d      }	|j                  d      }
|j                  d      }|rt%        |      j'                  |      nd| _        |	rt%        |	      j'                  |      nd| _        |
rt%        |
      j'                  |      nd| _        |rt%        |      j'                  |      nd| _        |j                  d      | _        |j                  d      | _        |j                  d      }|r(|j                  dd      rdnd}|j                  |      }ni }d}|r|j                  d      nd| _        |r|j                  dd      nd| _        |r |j                  dj                  |            nd| _        |j                  d      }|j                  d      | _        |j                  d      | _        y)av   A Microsoft Teams chat message
        :param parent: parent object
        :type parent: Channel, Chat, or ChannelMessage
        :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)
        r5   r6   r7   N	replyToId/replies/{message_id}
message_id/messages/{message_id}r;   r<   r=   messageTypesubjectsummary
importancewebUrlcreatedDateTimelastModifiedDateTimelastEditedDateTimedeletedDateTimechatIdchannelIdentityfromuserapplicationr?   z{}IdentityTypebodycontentTypecontent)rC   r3   rD   rE   rF   rG   rH   reply_to_idrI   rJ   rK   r<   message_typeri   rj   rk   web_urltimezoner   
astimezonecreated_datelast_modified_datelast_edited_datedeleted_datechat_idchannel_identityfrom_idfrom_display_name	from_typecontent_typerx   )rP   r2   r3   rQ   rR   r7   rS   local_tzcreatedlast_modified	last_editdeleted	sent_fromfrom_key	from_datarv   rT   s                   r   rK   zChatMessage.__init__a   s@    cIJJ!'6::SZZ 4 4b9
#- 

?D9 H6<GFOT2$ 	 &>>+65<<>> = +O 7==>> > +O m_E(.V__FJJz4J' 	 	)
 'NN=9!~~i0 "~~i0$..6!~~h/==))..!23"'=>NN#78	..!23 ! "'N55&* 	 ' #("6"A"A#,0 	
 # !&i 0 ; ;!(, 	
 ! "'N55&* 	
 "~~h/ !+/@ ANN6*	!*vt!<v-H!h/IIH /8y}}T*T 9B "+}/3"5GK 	
 3< ###H-/AE 	 ~~f% !HH]3xx	*r   c                 8    dj                  | j                        S )NzChatMessage: {})rI   r   rV   s    r   rW   zChatMessage.__repr__   s     ''(>(>??r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zChatMessage.__str__   r\   r   r]   r_   s   @r   ra   ra   ^   s    *!%4 e+N@r   ra   c                   F     e Zd ZdZdddZeZ fdZd Zd	dZ	d
dZ
 xZS )ChannelMessageF A Microsoft Teams chat message that is the start of a channel thread z/repliesrd   )get_replies	get_replyc                     t        |   di | |j                  | j                  i       }|j                  d      }|j                  d      | _        |j                  d      | _        y)r   rr   teamId	channelIdNr   )rJ   rK   rD   rE   team_id
channel_id)rP   rQ   rR   r   rT   s       r   rK   zChannelMessage.__init__   s]    "6"ZZ 4 4b9
%>>*;<'++H5*..{;r   c                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns a specified reply to the channel chat message
        :param message_id: the message_id of the reply to retrieve
        :type message_id: str or int
        :rtype: ChatMessage
        r   re   Nr2   r   	build_url
_endpointsrD   rI   r3   jsonmessage_constructorrE   rP   rf   urlresponsedatas        r   r   zChannelMessage.get_reply   s     nnOO,33z3JL88<<$}}'t'' Ht H+/+?+?*FH 	Hr   c           	         | j                  | j                  j                  d            }|s|	|t        kD  rt        }d|r|n|i}| j                  j                  ||      }|sg S |j                         }|j                  t        d      }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ }	}|r|rt        | |	| j                  ||      S |	S c c}w )	z Returns a list of replies to the channel chat message
        :param int limit: number of replies to retrieve
        :param int batch: number of replies to be in each data set
        :rtype: list or Pagination
        r   N$topparamsvaluer2   r2   r   constructor	next_linklimitr   
r   r   rD   MAX_BATCH_CHAT_MESSAGESr3   r   r   r   rE   r   )
rP   r   batchr   r   r   r   r   replyrepliess
             r   r   zChannelMessage.get_replies   s    nnT__00?@%-53J+J+E5%e488<<F<3I}}HH.5	 !%" 57 ,4++ M4 M/3/C/CU.KM 7 7 YT*.*B*B(1@ @ N7   !'C*c                 (   t        |t              r|nd||di}| j                  | j                  j	                  d            }| j
                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )a   Sends a reply to the channel chat message
        :param content: str of text, str of html, or dict representation of json body
        :type content: str or dict
        :param str content_type: 'text' to render the content as text or 'html' to render the content as html
        rv   rw   rx   r   r   Nr2   r   

isinstancedictr   r   rD   r3   postr   r   rE   rP   rx   r   r   r   r   s         r   
send_replyzChannelMessage.send_reply  s     %Wd3wLWE:GnnT__00?@88==4=0}}'t'' Ht H+/+?+?*FH 	Hr   NNNtext)r   r   r   r   r   ra   r   rK   r   r   r   r^   r_   s   @r   r   r      s1    P!+68J &	<H$<Hr   r   c                   n     e Zd ZdZdddddZeZeZddd fd	
Z	dd
Z
d ZddZd Zd Zd Zd Z xZS )Chatz A Microsoft Teams chat 	/messagesrg   z/membersr8   )get_messagesget_messageget_members
get_memberNr1   c                @   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  | j                        }dj                  ||      }t        
| %  |r|j                  n|j                  d      |	       |j                  d
      | _        |j                  d      | _        |j                  d      | _        |j                  d      }|j                  d      }| j                  j                  }	|rt        |      j!                  |	      nd| _        |r t        |      j!                  |	      | _        yd| _        y)aS   A Microsoft Teams chat
        :param parent: parent object
        :type parent: Teams
        :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)
        r5   r6   r7   Nz/chats/{chat_id})r   r;   r<   r=   topicchatTyperl   rm   lastUpdatedDateTime)rC   r3   rD   rE   rF   rG   rH   rI   rJ   rK   r<   r   	chat_typer{   r|   r   r}   r~   last_update_date)rP   r2   r3   rQ   rR   r7   rS   r   last_updater   rT   s             r   rK   zChat.__init__.  s{    cIJJ!'6::SZZ 4 4b9
#- 

?D9 H6<GFOT2$ 	,33DNN3Km_E(.V__FJJz4J' 	 	)  ^^G,
 $
3!~~h/..!23 nn%:;==)) ! "'N55&* 	
 % !&k 2 = =!*. 	r   c           	         | j                  | j                  j                  d            }|s|	|t        kD  rt        }d|r|n|i}| j                  j                  ||      }|sg S |j                         }|j                  t        d      }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ }	}|r|rt        | |	| j                  ||      S |	S c c}w )	z Returns a list of chat messages from the chat
        :param int limit: number of replies to retrieve
        :param int batch: number of replies to be in each data set
        :rtype: list[ChatMessage] or Pagination of ChatMessage
        r   Nr   r   r   r2   r   r   r   
rP   r   r   r   r   r   r   r   messagemessagess
             r   r   zChat.get_messages[      nnT__00@A%-53J+J+E5%e488<<F<3I}}HH.5	 $(88GR#8: -D,, PD P040D0Dg/NP : : YT*.*B*B(1@ @ O:r   c                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns a specified message from the chat
        :param message_id: the message_id of the message to receive
        :type message_id: str or int
        :rtype: ChatMessage
        r   re   Nr2   r   r   r   s        r   r   zChat.get_messagey  s     nnOO.555LN88<<$}}'t'' Ht H+/+?+?*FH 	Hr   c                 (   t        |t              r|nd||di}| j                  | j                  j	                  d            }| j
                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )a(   Sends a message to the chat
        :param content: str of text, str of html, or dict representation of json body
        :type content: str or dict
        :param str content_type: 'text' to render the content as text or 'html' to render the content as html
        :rtype: ChatMessage
        rv   r   r   r   Nr2   r   r   r   s         r   send_messagezChat.send_message       %Wd3wLWE:G nnT__00@A88==4=0}}'t'' Ht H+/+?+?*FH 	Hr   c           	      :   | j                  | j                  j                  d            }| j                  j                  |      }|sy|j	                         }|j                  dg       D cg c]"  } | j
                  dd| i| j                  |i$ }}|S c c}w )zY Returns a list of conversation members
        :rtype: list[ConversationMember]
        r   Nr   r2   r   )r   r   rD   r3   r   member_constructorrE   )rP   r   r   r   membermemberss         r   r   zChat.get_members  s     nnT__00?@88<<$}} "&'2!68 +4** M$ M.2.B.BF-KM 8 8 8s   -'Bc                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )zReturns a specified conversation member
        :param str membership_id: membership_id of member to retrieve
        :rtype: ConversationMember
        r   r9   Nr2   r   )r   r   rD   rI   r3   r   r   rE   )rP   r:   r   r   r   s        r   r   zChat.get_member  s    
 nnT__00>EE' F ) *88<<$}}&t&& Gd G*.*>*>)EG 	Gr   c                 8    dj                  | j                        S )NzChat: {})rI   r   rV   s    r   rW   zChat.__repr__  s      00r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zChat.__str__  r\   r   r   r   )r   r   r   r   r   ra   r   r0   r   rK   r   r   r   r   r   rW   r[   r^   r_   s   @r   r   r   $  sX    ""-!9!+ :<J
 &+!%4 +/Z<HH(G1r   r   c                   @     e Zd ZdZi Zddd fd
Zd Zd Zd Z xZ	S )Presencez Microsoft Teams Presence  Nr1   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  d	      | _        |j                  d
      | _        y)ah   Microsoft Teams Presence

        :param parent: parent object
        :type parent: Teams
        :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)
        r5   r6   r7   Nr;    r<   r=   availabilityactivity)rC   r3   rD   rE   rF   rG   rH   rI   rJ   rK   r<   r   r   rP   r2   r3   rQ   rR   r7   rT   s         r   rK   zPresence.__init__  s     cIJJ!'6::SZZ 4 4b9
 $- 

?D9 H6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	) 'NN>: #z2r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zPresence.__str__  r\   r   c                 8    dj                  | j                        S )Nzavailability: {})rI   r   rV   s    r   rW   zPresence.__repr__  s    !(():):;;r   c                 4    | j                   |j                   k(  S rY   rF   rP   others     r   __eq__zPresence.__eq__      ~~00r   
r   r   r   r   r   rK   r[   rW   r   r^   r_   s   @r   r   r     s%    %J!%4 (3T<1r   r   c                   `     e Zd ZdZdddZeZddd fd
Zd Zdd	Z	dd
Z
d Zd Zd Z xZS )Channelz A Microsoft Teams channel r   rg   )r   r   Nr1   c                X   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  | j                        }dj                  ||      }t        | %  |r|j                  n|j                  d      |	       |j                  | j                  d
      d      | _        |j                  d      | _        |j                  d      | _        y)aq   A Microsoft Teams channel

        :param parent: parent object
        :type parent: Teams or Team
        :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)
        r5   r6   r7   N/channels/{channel_id}r   r;   r<   r=   r?   r   descriptionrA   )rC   r3   rD   rE   rF   rG   rH   rI   rJ   rK   r<   _ccrL   r   rA   rO   s          r   rK   zChannel.__init__   s    cIJJ!'6::SZZ 4 4b9
#- 

?D9 H6<GFOT2$ 	 399~~ : 'm_E(.V__FJJz4J' 	 	) 'NN488M+BBG%>>-8^^G,
r   c                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns a specified channel chat messages
        :param message_id: number of messages to retrieve
        :type message_id: int or str
        :rtype: ChannelMessage
        r   re   Nr2   r   r   r   s        r   r   zChannel.get_message&  s     nnOO.555LN88<<$}}'t'' Ht H+/+?+?*FH 	Hr   c           	         | j                  | j                  j                  d            }|s|	|t        kD  rt        }d|r|n|i}| j                  j                  ||      }|sg S |j                         }|j                  t        d      }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ }	}|r|rt        | |	| j                  ||      S |	S c c}w )	z Returns a list of channel chat messages
        :param int limit: number of messages to retrieve
        :param int batch: number of messages to be in each data set
        :rtype: list[ChannelMessage] or Pagination of ChannelMessage
        r   Nr   r   r   r2   r   r   r   r   s
             r   r   zChannel.get_messages7  r   r   c                 (   t        |t              r|nd||di}| j                  | j                  j	                  d            }| j
                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )a.   Sends a message to the channel
        :param content: str of text, str of html, or dict representation of json body
        :type content: str or dict
        :param str content_type: 'text' to render the content as text or 'html' to render the content as html
        :rtype: ChannelMessage
        rv   r   r   r   Nr2   r   r   r   s         r   r   zChannel.send_messageU  r   r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zChannel.__str__i  r\   r   c                 8    dj                  | j                        S )NzChannel: {}rI   rL   rV   s    r   rW   zChannel.__repr__l  s    ##D$5$566r   c                 4    | j                   |j                   k(  S rY   r   r   s     r   r   zChannel.__eq__o  r   r   r   r   )r   r   r   r   r   r   r   rK   r   r   r   r[   rW   r   r^   r_   s   @r   r   r     sF    %"-!9;J )!%4 $-LH"<H(71r   r   c                   V     e Zd ZdZdddZeZddd fd
Zd Zd	 Z	d
 Z
d Zd Z xZS )Teamz A Microsoft Teams team z	/channelsr   )get_channelsget_channelNr1   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  | j                        }dj                  ||      }t        | %  |r|j                  n|j                  d      |	       |j                  | j                  d
      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        y)af   A Microsoft Teams team

        :param parent: parent object
        :type parent: Teams
        :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)
        r5   r6   r7   Nz/teams/{team_id}r   r;   r<   r=   r?   r   r   
isArchivedrl   )rC   r3   rD   rE   rF   rG   rH   rI   rJ   rK   r<   r   rL   r   is_archivedr{   rO   s          r   rK   zTeam.__init__{  s=    cIJJ!'6::SZZ 4 4b9
 $- 

?D9 H6<GFOT2$ 	 -33DNN3Km_E(.V__FJJz4J' 	 	)
 'NN488M+BBG%>>$((=*A2F%>>$((<*@"E "~~dhhx&8"=r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zTeam.__str__  r\   r   c                 8    dj                  | j                        S )NzTeam: {}r   rV   s    r   rW   zTeam.__repr__  s      !2!233r   c                 4    | j                   |j                   k(  S rY   r   r   s     r   r   zTeam.__eq__  r   r   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 )zL Returns a list of channels the team

        :rtype: list[Channel]
        r   r   r2   r   )r   r   rD   r3   r   channel_constructorrE   )rP   r   r   r   channels        r   r   zTeam.get_channels  s    
 nnT__00@A88<<$I}}  $xx46 )(( L L,0,@,@'+JL 6 	6 6   .'Bc                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns a channel of the team

        :param channel_id: the team_id of the channel to be retrieved.

        :rtype: Channel
        r   r   Nr2   r   r   r   rD   rI   r3   r   r	  rE   )rP   r   r   r   r   s        r   r   zTeam.get_channel  sy     nnT__00?FFR\F]^88<<$}}'t''TtT8L8Ld7STTr   )r   r   r   r   r   r   r	  rK   r[   rW   r   r   r   r^   r_   s   @r   r   r   s  s@    ""-!9;J "!%4 '>R416"Ur   r   c                   @     e Zd ZdZi Zddd fd
Zd Zd Zd Z xZ	S )Appz A Microsoft Teams app Nr1   c                   |r|rt        d      |r|j                  n|| _        |j                  | j                  i       }|j                  d      | _        |j                  dd      xs |rt        |dd      nd}dj                  |d      }t        | %  |r|j                  n|j                  d      |       |j                  | j                  d	      i       | _        y)
ae   A Microsoft Teams app

        :param parent: parent object
        :type parent: Teams
        :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)
        r5   r6   r7   Nr;   r   r<   r=   teamsAppDefinition)rC   r3   rD   rE   rF   rG   rH   rI   rJ   rK   r<   r   app_definitionr   s         r   rK   zApp.__init__  s     cIJJ!'6::SZZ 4 4b9
 $- 

?D9 H6<GFOT2$ 	 mR8(.V__FJJz4J' 	 	)
 )nnTXX6J-K-/1r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zApp.__str__  r\   r   c                 V    dj                  | j                  j                  d            S )NzApp: {}r?   )rI   r  rD   rV   s    r   rW   zApp.__repr__   s$     3 3 7 7 FGGr   c                 4    | j                   |j                   k(  S rY   r   r   s     r   r   z
App.__eq__  r   r   r   r_   s   @r   r  r    s&    !J!%4 $1LH1r   r  c                        e Zd ZdZddddddddd	d
d
ZeZeZe	Z
eZeZddd fd
Zd Zd Zd ZdedefdZdedefdZddZd ZddZd ZddZd Zd Z xZ S )Teamsz A Microsoft Teams classz/me/presencez/users/{user_id}/presencez/me/presence/setPresencez%/me/presence/setUserPreferredPresencez/me/joinedTeamsz/teams/{team_id}/channelsz&/teams/{team_id}/channels/{channel_id}z9/teams/{team_id}/installedApps?$expand=teamsAppDefinitionz	/me/chats)
get_my_presenceget_user_presenceset_my_presenceset_my_user_preferred_presenceget_my_teamsr   create_channelr   get_apps_in_teamget_my_chatsNr1   c                    |r|rt        d      |r|j                  n|| _        |j                  dd      }t        |   |r|j
                  n|j                  d      |       y)a`   A Teams object

        :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)
        r5   r7   r   r<   r=   N)rC   r3   rG   rJ   rK   r<   rD   )rP   r2   r3   rQ   r7   rT   s        r   rK   zTeams.__init__  sc     cIJJ!'6::S 

?#%'(.V__FJJz4J' 	 	)r   c                 "    | j                         S rY   rZ   rV   s    r   r[   zTeams.__str__2  r\   r   c                      y)NzMicrosoft Teamsr   rV   s    r   rW   zTeams.__repr__5  s     r   c                     | j                  | j                  j                  d            }| j                  j                  |      }|sy|j	                         } | j
                  dd| i| j                  |iS )zH Returns my availability and activity

        :rtype: Presence
        r  Nr2   r   )r   r   rD   r3   r   presence_constructorrE   )rP   r   r   r   s       r   r  zTeams.get_my_presence8  sx     nnT__001BCD88<<$}}(t(( I I,0,@,@$+GI 	Ir   r   r   c                     | j                  | j                  j                  d            }||j                  |j                  |d}| j                  j                  ||      }|r| j                         S dS )a  Sets my presence status

        :param session_id: the session/capplication id.
        :param availability: the availability.
        :param activity: the activity.
        :param activity: the expiration_duration when status will be unset.
        :rtype: Presence
        r  )	sessionIdr   r   expirationDutaionr   Nr   r   rD   r   r3   r   r  )rP   
session_idr   r   expiration_durationr   r   r   s           r   r  zTeams.set_my_presenceJ  so      nnT__001BCD $(.. !4	
 88==4=0)1t##%;t;r   c                     | j                  | j                  j                  d            }|j                  |j                  |d}| j                  j                  ||      }|r| j                         S dS )zSets my user preferred presence status

        :param availability: the availability.
        :param activity: the activity.
        :param activity: the expiration_duration when status will be unset.
        :rtype: Presence
        r  )r   r   r'  r   Nr(  )rP   r   r   r*  r   r   r   s          r   r  z$Teams.set_my_user_preferred_presenceg  sl     nnT__001QRS ).. !4
 88==4=0)1t##%;t;r   c                    | j                  | j                  j                  d      j                  |            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )zRReturns specific user availability and activity

        :rtype: Presence
        r  )rM   Nr2   r   )r   r   rD   rI   r3   r   r$  rE   )rP   rM   rA   r   r   r   s         r   r  zTeams.get_user_presence  s~     nnOO 34;;G;L
 88<<$}}(t((UU9M9Mt8TUUr   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 )zJ Returns a list of teams that I am in

        :rtype: list[Team]
        r  r   r2   r   )r   r   rD   r3   r   team_constructorrE   )rP   r   r   r   sites        r   r  zTeams.get_my_teams  s     nnT__00@A88<<$I}} "-/ "D!!NN$2F2F1MN/ 	/ /r  c           	         | j                  | j                  j                  d            }|s|	|t        kD  rt        }d|r|n|i}| j                  j                  ||      }|sg S |j                         }|j                  t        d      }|j                  dg       D cg c]"  } | j                  dd| i| j                  |i$ }	}|r|rt        | |	| j                  ||      S |	S c c}w )	z Returns a list of chats that I am in
        :param int limit: number of chats to retrieve
        :param int batch: number of chats to be in each data set
        :rtype: list[ChatMessage] or Pagination of Chat
        r  Nr   r   r   r2   r   r   )
r   r   rD   MAX_BATCH_CHATSr3   r   r   chat_constructorrE   r   )
rP   r   r   r   r   r   r   r   r   chatss
             r   r  zTeams.get_my_chats  s    nnT__00@A%-5?+B#E5%e488<<F<3I}}HH.5	 $(88GR#8: '&& Pd P040D0Dg/NP : : YT*.*?*?(1@ @ L:r   c           	      Z   | j                  | j                  j                  d      j                  |            }| 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 channels of a specified team

        :param team_id: the team_id of the channel to be retrieved.

        :rtype: list[Channel]
        r   r  r   r2   r   r  )rP   r   r   r   r   r
  s         r   r   zTeams.get_channels  s     nnOO/66w6GI 88<<$I}}
  88GR02  %D$$ HD H(,(<(<g'FH2 	2 2   >'B(c                 .   | j                  | j                  j                  d      j                  |            }|r||d}nd|i}| j                  j                  ||      }|sy|j                         } | j                  dd| i| j                  |iS )	z Creates a channel within a specified team

        :param team_id: the team_id where the channel is created.
        :param display_name: the channel display name.
        :param description: the channel description.
        :rtype: Channel
        r   r  )r?   r   r?   r   Nr2   r   )	r   r   rD   rI   r3   r   r   r	  rE   )rP   r   rL   r   r   r   r   s          r   r  zTeams.create_channel  s     nnOO/66w6GI +*D |D 88==4=0}}'t'' Ht H+/+?+?*FH 	Hr   c                    | j                  | j                  j                  d      j                  ||            }| j                  j                  |      }|sy|j                         } | j                  dd| i| j                  |iS )z Returns the channel info for a given channel

        :param team_id: the team_id of the channel.
        :param channel_id: the channel_id of the channel.

        :rtype: list[Channel]
        r   )r   r   Nr2   r   r  )rP   r   r   r   r   r   s         r   r   zTeams.get_channel  s     nnOO.55gCM 6 OP 88<<$}}'t'' Ht H+/+?+?*FH 	Hr   c           	      Z   | j                  | j                  j                  d      j                  |            }| 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 apps of a specified team

        :param team_id: the team_id of the team to get the apps of.

        :rtype: list[App]
        r  r  r   r2   r   )r   r   rD   rI   r3   r   app_constructorrE   )rP   r   r   r   r   r/  s         r   r  zTeams.get_apps_in_team  s     nnOO 23::7:KM88<<$I}} "-/ !D  MM1E1Et0LM/ 	/ /r5  r   rY   )!r   r   r   r   r   r   r$  r   r.  r   r	  r  r9  r   r2  rK   r[   rW   r  r   r   r  r&   r,   r  r  r  r  r   r  r   r  r^   r_   s   @r   r  r    s    " *85*Q)35?W#J $!O!%4 ),!I$< #< 	<:<+< $<4V&/$<2.H@H./r   r  )loggingenumr   dateutil.parserr   utilsr   r   r   	getLoggerr   logr   r1  r   r   r&   r,   r0   ra   r   r   r   r   r   r  r  r   r   r   <module>r@     s      ! > >g! "4 "t D  & &Rn, nbRH[ RHjX< Xv61| 61rx1l x1vZU< ZU~21, 21j^/L ^/r   