
    3fi                         d dl Zd dlZd dlmZ ddlmZ ddlmZm	Z	m
Z
mZ  ej                  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   )Message)NEXT_LINK_KEYWORDApiComponentOutlookWellKnowFolderNames
Paginationc                       e Zd ZdZdZdZdZy)ExternalAudiencez"Valid values for externalAudience.nonecontactsOnlyallN)__name__
__module____qualname____doc__NONECONTACTSONLYALL     J/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/O365/mailbox.pyr   r      s    ,D!L
Cr   r   c                       e Zd ZdZdZdZdZy)AutoReplyStatuszValid values for status.disabledalwaysEnabled	scheduledN)r   r   r   r   DISABLEDALWAYSENABLED	SCHEDULEDr   r   r   r   r      s    "H#MIr   r   c                   H    e Zd ZdZddd fd
Zd Zed        Zej                  d        Zed        Z	e	j                  d	        Z	ed
e
fd       Zej                  e
j                  fde
fd       Zed
efd       Zej                  ej                  fdefd       Z xZS )AutomaticRepliesSettingszThe  AutomaticRepliesSettingss.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       }t        |j                  | j                  d      d            | _        |j                  | j                  d      d      | _        |j                  | j                  d	      d      | _        |j                  | j                  d
      i       }| j                  |      | _        |j                  | j                  d      i       }| j                  |      | _        t#        |j                  | j                  d      d            | _        y)a  Representation of the AutomaticRepliesSettings.

        :param parent: parent object
        :type parent: Mailbox
        :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r)   r(   externalAudience externalReplyMessageinternalReplyMessagescheduledEndDateTimescheduledStartDateTimestatus)
ValueErrorr%   popgetattrsuper__init__r)   get_cloud_data_keyr   _cc,_AutomaticRepliesSettings__external_audienceexternal_reply_messageinternal_reply_message_parse_date_time_time_zone0_AutomaticRepliesSettings__scheduled_enddatetime2_AutomaticRepliesSettings__scheduled_startdatetimer   !_AutomaticRepliesSettings__status)	selfr$   r%   kwargsr(   
cloud_datascheduled_enddatetime_obscheduled_startdatetime_ob	__class__s	           r   r6   z!AutomaticRepliesSettings.__init__#   s    cIJJ!'6::S 

?D9 
6<GFOT2$ 	 	(.V__FJJz4J' 	 	

 ZZ 4 4b9
#3NN488$67<$
 
 '1nnHH+,b'
#
 '1nnHH+,b'
# $.>>$((;Q2RTV#W '+'F'F$(
$ &0^^HH-.&
" *.)H)H&*
& (
txx7I2(NOr   c                 "    | j                         S )zMRepresentation of the AutomaticRepliesSettings via the Graph api as a string.__repr__rA   s    r   __str__z AutomaticRepliesSettings.__str__X       }}r   c                     | j                   S )zScheduled Start Time of auto reply.

        :getter: get the scheduled_startdatetime time
        :setter: set the scheduled_startdatetime time
        :type: datetime
        )r?   rJ   s    r   scheduled_startdatetimez0AutomaticRepliesSettings.scheduled_startdatetime\   s     ---r   c                    t        |t        j                        st        d      t        |t        j                        s5t        j                  |j
                  |j                  |j                        }|j                  .|j                  | j                  j                        }|| _        y |j                  | j                  j                  k7  r%|j                  | j                  j                        }|| _        y )Nz9'scheduled_startdatetime' must be a valid datetime objecttzinfo)
isinstancedtdater2   datetimeyearmonthdayrQ   replacer)   timezone
astimezoner?   rA   values     r   rN   z0AutomaticRepliesSettings.scheduled_startdatetimef   s    %)K  %-KK

EKKCE<<MM)?)?M@E */& \\T]]333$$T]]%;%;<E).&r   c                     | j                   S )zScheduled End Time of auto reply.

        :getter: get the scheduled_enddatetime time
        :setter: set the reminder time
        :type: datetime
        )r>   rJ   s    r   scheduled_enddatetimez.AutomaticRepliesSettings.scheduled_enddatetimev   s     +++r   c                    t        |t        j                        st        d      t        |t        j                        s5t        j                  |j
                  |j                  |j                        }|j                  .|j                  | j                  j                        }|| _        y |j                  | j                  j                  k7  r%|j                  | j                  j                        }|| _        y )Nz7'scheduled_enddatetime' must be a valid datetime objectrP   )rR   rS   rT   r2   rU   rV   rW   rX   rQ   rY   r)   rZ   r[   r>   r\   s     r   r_   z.AutomaticRepliesSettings.scheduled_enddatetime   s    %)VWW%-KK

EKKCE<<MM)?)?M@E (-$ \\T]]333$$T]]%;%;<E',$r   returnc                     | j                   S )zStatus of auto reply.

        :getter: get the status of auto reply
        :setter: set the status of auto reply
        :type: autoreplystatus
        )r@   rJ   s    r   r1   zAutomaticRepliesSettings.status   s     }}r   r]   c                 $    t        |      | _        y N)r   r@   r\   s     r   r1   zAutomaticRepliesSettings.status   s    '.r   c                     | j                   S )zExternal Audience of auto reply.

        :getter: get the external audience of auto reply
        :setter: set the external audience of auto reply
        :type: autoreplystatus
        )r:   rJ   s    r   external_audiencez*AutomaticRepliesSettings.external_audience   s     '''r   c                 H    |st         j                  }t        |      | _        y rd   )r   r   r:   r\   s     r   rf   z*AutomaticRepliesSettings.external_audience   s    $((E#3E#: r   )r   r   r   r   r6   rK   propertyrN   setterr_   r   r1   r   r   rf   r   __classcell__rF   s   @r   r"   r"       s    )!%4 3Pj . . ##/ $/ , , !!- "-    ]].=.F.F /O / / (#3 ( ( :J:N:N ;'7 ; ;r   r"   c                   B     e Zd ZdZddiZeZddd fd
Zd Zd Z	 xZ
S )	MailboxSettingszThe MailboxSettings.settings/mailboxSettingsNr#   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      |       |j                  | j                  i       }|j                  d      } | j                  d
d| i| j                  |i| _
        |j                  d      | _        |j                  d	      | _        y)aw  Representation of the MailboxSettings.

        :param parent: parent object
        :type parent: Mailbox
        :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)
        r'   r(   Nr)   r*   automaticRepliesSettingr$   timeZoneworkingHoursr   )r2   r%   r3   r4   r5   r6   r)   r7   r8   autoreply_constructorautomaticrepliessettingsrZ   workinghours)rA   r$   r%   rB   r(   rC   autorepliessettingsrF   s          r   r6   zMailboxSettings.__init__   s     cIJJ!'6::S 

?D9 
6<GFOT2$ 	 	(.V__FJJz4J' 	 	

 ZZ 4 4b9
(nn-FG )C(B(B )
)
 002EF)
% #z2 'NN>:r   c                 "    | j                         S )zCRepresentation of the MailboxSetting via the Graph api as a string.rH   rJ   s    r   rK   zMailboxSettings.__str__   rL   r   c           	      p   | j                  | j                  j                  d            }| j                  }| j                  } |d      |j
                  j                   |d      |j                  j                   |d      |j                   |d      |j                  i}|j
                  t        j                  k(  rH| j                  |j                        | |d      <   | j                  |j                        | |d      <    |d      |i}| j                  j!                  ||	      }t#        |      S )
z[Save the MailboxSettings.

        :return: Success / Failure
        :rtype: bool
        rn   r1   r+   r.   r-   r0   r/   rq   data)	build_url
_endpointsr7   r9   ru   r1   r]   rf   r<   r;   r   r    _build_date_time_time_zonerN   r_   r%   patchbool)rA   urlccarsautomatic_reply_settingsr{   responses          r   savezMailboxSettings.save   s"    nnT__00<=XX++xL#****!"C$9$9$?$?%&(B(B%&(B(B	$
  ::222 //0K0KL %+,
 //0I0IJ %)* ,-/GH88>>#D>1H~r   )r   r   r   r   r}   r"   rt   r6   rK   r   rj   rk   s   @r   rm   rm      s2     	&J 5!%4 %;Nr   rm   c            	            e Zd ZdZdddddddd	d
ZeZddd fd
Zd Zd Z	d Z
d%dddddZd&dddZ	 d'ddddddZd ZddddZd(dZd Zd)dZd Zd  Zdd!d"Zd# Zd$ Z xZS )*FolderzA Mail Folder representation.z/mailFoldersz/mailFolders/{id}/childFoldersz/mailFolders/{id}z	/messagesz/mailFolders/{id}/messagesz/mailFolders/{id}/copyz/mailFolders/{id}/movez/messages/{id})root_folderschild_folders
get_folderroot_messagesfolder_messagescopy_foldermove_foldermessageNr#   c                   |r|rt        d      |r|j                  n|| _        t        |t              r|nd| _        |j                  dd      | _        |j                  dd      xs |rt        |dd      nd}t        | %  |r|j                  n|j                  d      |       |j                  | j                  i       }|j                  | j                  d      |j                  d	d
            | _        | j                  du r|j                  | j                  d      |j                  dd            | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        t(        j*                  j-                         | _        yd| _        y)ak  Create an instance to represent the specified folder in given
        parent folder

        :param parent: parent folder/account for this folder
        :type parent: mailbox.Folder or 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)
        :param str name: name of the folder to get under the parent (kwargs)
        :param str folder_id: id of the folder to get under the parent (kwargs)
        r'   NrootFr(   r)   r*   displayNamenamer,   id	folder_idparentFolderIdchildFolderCountr   unreadItemCounttotalItemCount)r2   r%   rR   r   r$   r3   r   r4   r5   r6   r)   r7   r8   r9   r   r   	parent_idchild_folders_countunread_items_counttotal_items_countrS   rU   now
updated_at)rA   r$   r%   rB   r(   rC   rF   s         r   r6   zFolder.__init__  s    cIJJ!'6::S *66 :f JJvu-	 

?D9 
6<GFOT2$ 	 	(.V__FJJz4J' 	 	

 ZZ 4 4b9
 NN488M#:FJJvr<RS	99 (^^

; =DN (^^DHH5E,FMDN (2~~dhh?Q6RTU'VD$&0nnTXX>O5PRS&TD#%/^^DHH=M4NPQ%RD" kkoo/DO $DNr   c                 "    | j                         S rd   rH   rJ   s    r   rK   zFolder.__str__I  s    }}r   c                 N    dj                  | j                  | j                        S )Nz{} from resource: {})formatr   r(   rJ   s    r   rI   zFolder.__repr__L  s    %,,TYY8J8JKKr   c                 4    | j                   |j                   k(  S rd   r   )rA   others     r   __eq__zFolder.__eq__O  s    ~~00r   )queryorder_bybatchc          	      <   | j                   r+| j                  | j                  j                  d            }nD| j                  | j                  j                  d      j	                  | j
                              }||| j                  j                  kD  r| j                  j                  }d|r|n|i}|r||d<   |r5t        |t              r||d<   n|j                  |j                                | j                  j                  ||      }|sg S |j                         }t        | d	t        |             }	|j                  d
g       D 
cg c]  }
 |	dd| i| j                   |
i }}
|j                  t"        d      }|r|rt%        | ||	||      S |S c c}
w )aH  Return a list of child folders matching the query.

        :param int limit: max no. of folders to get. Over 999 uses batch.
        :param query: applies a filter to the request such as
         "displayName eq 'HelloFolder'"
        :type query: Query or str
        :param order_by: orders the result set based on this condition
        :type order_by: Query or str
        :param int batch: batch size, retrieves items in
         batches allowing to retrieve more items than the limit.
        :return: list of folders
        :rtype: list[mailbox.Folder] or Pagination
        r   r   r   N$top$orderby$filterparamsfolder_constructorr]   r$   )r$   r{   constructor	next_linklimitr   )r   r|   r}   r7   r   r   r)   max_top_valuerR   strupdate	as_paramsr%   jsonr4   typer8   r   r	   )rA   r   r   r   r   r   r   r   r{   
self_classfolderfoldersr   s                r   get_folderszFolder.get_foldersR  s    99..!4!4^!DEC..##O4;;t~~;NC =EDMM$?$??MM//E5%e4!)F:%%$)y!eoo/088<<F<3I}} T#7dD
 ((7B/
 EdEt';';V&DE
 
 HH.5	Y&#  N
s   FF)download_attachmentsc                   ||t        d      || j                  | j                  j                  d      j	                  |            }d}|r(|j
                  s|j                  r|j                         }| j                  j                  ||      }|sy|j                         } | j                  d
| |d| j                  |iS t        | j                  d||            }|r|d	   S dS )a  
        Get one message from the query result.
        A shortcut to get_messages with limit=1

        :param object_id: the message id to be retrieved.
        :param query: applies a filter to the request such as
         "displayName eq 'HelloFolder'"
        :type query: Query or str
        :param bool download_attachments: whether or not to download attachments
        :return: one Message
        :rtype: Message or None
        Nz Must provide object id or query.r   r   r   r$   r   r   )r   r   r   r   r   )r2   r|   r}   r7   r   has_selectshas_expandsr   r%   r   message_constructorr8   listget_messages)	rA   	object_idr   r   r   r   r   r   messagess	            r   get_messagezFolder.get_message  s    ?@@ ..!4!4Y!?!F!F)!F!TUCF%++u/@/@*xx||C|7HmmoG+4++ %9 ''1  !!5?S " H #+8A;44r   )r   r   r   r   c                     j                   r+ j                   j                  j                  d            }nD j                   j                  j                  d      j	                   j
                              }|s1|| j                  j                  kD  r j                  j                  }d|r|n|i}|r||d<   |r5t        |t              r||d<   n|j                  |j                                 j                  j                  ||      }|st        d	      S |j                         }	 fd
|	j                  dg       D        }
|	j                  t        d      }|r|rt!         |
 j"                  ||      S |
S )a  
        Downloads messages from this folder

        :param int limit: limits the result set. Over 999 uses batch.
        :param query: applies a filter to the request such as
         "displayName eq 'HelloFolder'"
        :type query: Query or str
        :param order_by: orders the result set based on this condition
        :type order_by: Query or str
        :param int batch: batch size, retrieves items in
         batches allowing to retrieve more items than the limit.
        :param bool download_attachments: whether or not to download attachments
        :return: list of messages
        :rtype: list[Message] or Pagination
        r   r   r   Nr   r   r   r   r   c              3   `   K   | ]%  } j                   dd j                  |i ' yw)r   Nr   )r   r8   ).0r   r   rA   s     r   	<genexpr>z&Folder.get_messages.<locals>.<genexpr>  sH      
  %D$$ %9 ''1
s   +.r]   )r$   r{   r   r   r   r   )r   r|   r}   r7   r   r   r)   r   rR   r   r   r   r%   iterr   r   r	   r   )rA   r   r   r   r   r   r   r   r   r{   r   r   s   `    `      r   r   zFolder.get_messages  sW   2 99..!4!4_!EFC..##$56===PC %-54==3N3N+NMM//E5%e4!)F:%%$)y!eoo/088<<F<38O}}
  88GR0
 HH.5	Y 44#%9  Or   c                    |sy| j                   r+| j                  | j                  j                  d            }nD| j                  | j                  j                  d      j	                  | j
                              }| j                  j                  || j                  d      |i      }|sy|j                         }t        | dt        |             } |d	d| i| j                  |iS )
zCreates a new child folder under this folder

        :param str folder_name: name of the folder to add
        :return: newly created folder
        :rtype: mailbox.Folder or None
        Nr   r   r   r   rz   r   r$   r   )r   r|   r}   r7   r   r   r%   postr9   r   r4   r   r8   )rA   folder_namer   r   r   r   s         r   create_child_folderzFolder.create_child_folder  s     99..!4!4^!DEC..##O4;;t~~;NC 88==DHH],C[+Q=RT#7dD
HH$*>*>)GHHr   )r   r   c                N   |r|rt        d      |s|st        d      |r=| j                  | j                  j                  d      j	                  |            }d}n| j
                  r+| j                  | j                  j                  d            }nD| j                  | j                  j                  d      j	                  | j                              }dj	                  | j                  d	      |      d
d}| j                  j                  ||      }|sy|r|j                         }n+|j                         j                  d      }|r|d   nd}|yt        | dt        |             } |d| j                  | j                  | j                  d| j                  |iS )aE  Get a folder by it's id or name

        :param str folder_id: the folder_id to be retrieved.
         Can be any folder Id (child or not)
        :param str folder_name: the folder name to be retrieved.
         Must be a child of this folder.
        :return: a single folder
        :rtype: mailbox.Folder or None
        zProvide only one of the optionszProvide one of the optionsr   r   Nr   r   z
{} eq '{}'r   r   )r   r   r   r]   r   r   )r%   r)   r(   r   )RuntimeErrorr|   r}   r7   r   r   r   r9   r%   r   r4   r   r)   r(   r8   )rA   r   r   r   r   r   r   r   s           r   r   zFolder.get_folder  s    @AA;<<..!4!4\!B!I!IY!I!WXCF yynnT__%8%8%HInnOO''8??4>>?R (..txx/FTF
 88<<F<3]]_F]]_((1F"(VAYdF~T#7dD
  
]],,
 ##V,	
 	
r   c                    t        | dd      }| j                  s|y| j                  |      }|y|j                  | _        |j                  rO| j                  rC|j                  | j                  k7  r*|j                  | _        |r| j                         nd| _        |j                  | _        |j                  | _        |j                  | _	        |j                  | _
        y)a  Re-download folder data
        Inbox Folder will be unable to download its own data (no folder_id)

        :param bool update_parent_if_changed: updates self.parent with new
         parent Folder if changed
        :return: Refreshed or Not
        :rtype: bool
        r   NFr   T)r4   r   r   r   r   get_parent_folderr$   r   r   r   r   )rA   update_parent_if_changedr   r   s       r   refresh_folderzFolder.refresh_folderU  s     D+t4	99	)95>KK	4>>1!'!1!10HD**,d  $*#=#= "(";";!'!9!9 ++r   c                     | j                   ry| j                  r| j                  S | j                  r!| j                  | j                        | _        | j                  S )zGet the parent folder from attribute self.parent or
        getting it from the cloud

        :return: Parent Folder
        :rtype: mailbox.Folder or None
        Nr   )r   r$   r   r   rJ   s    r   r   zFolder.get_parent_foldert  sF     99;;;;>>//DNN/CDK{{r   Tc                    | j                   ry|sy| j                  | j                  j                  d      j	                  | j
                              }| j                  j                  || j                  d      |i      }|sy|| _	        |sy|j                         }|j                  | j                  d      d      | _	        |j                  | j                  d      d	      | _        |j                  | j                  d
      d      | _        |j                  | j                  d      d      | _        |j                  | j                  d      d      | _        t        j                   j#                         | _        y)zChange this folder name

        :param str name: new name to change to
        :param bool update_folder_data: whether or not to re-fetch the data
        :return: Updated or Not
        :rtype: bool
        Fr   r   r   rz   Tr,   r   Nr   r   r   r   )r   r|   r}   r7   r   r   r%   r   r9   r   r   r   r   r   r   rS   rU   r   r   )rA   r   update_folder_datar   r   r   s         r   update_folder_namezFolder.update_folder_name  s-    99nnOO-444G
 88>>#TXXm-Dd,K>L	!JJtxx6;	DHH-=$>E#)::dhh7I.JA#N "(**TXX6G-H!"L!'DHH5E,F!J++//+r   c                    | j                   s| j                  sy| j                  | j                  j	                  d      j                  | j                              }| j                  j                  |      }|syd| _        y)zRDeletes this folder

        :return: Deleted or Not
        :rtype: bool
        Fr   r   NT)r   r   r|   r}   r7   r   r%   delete)rA   r   r   s      r   r   zFolder.delete  sj     99DNNnnOO-444G
 88??3'r   c                     t        |t              r|j                  n|}| j                  s| j                  r|sy| j	                  | j
                  j                  d      j                  | j                              }| j                  j                  || j                  d      |i      }|sy|j                         }t        | dt        |             } |d| j                  | j                  d| j                  |iS )	a  Copy this folder and it's contents to into another folder

        :param to_folder: the destination Folder/folder_id to copy into
        :type to_folder: mailbox.Folder or str
        :return: The new folder after copying
        :rtype: mailbox.Folder or None
        Nr   r   destinationIdrz   r   )r%   r(   r   )rR   r   r   r   r|   r}   r7   r   r%   r   r9   r   r4   r   r(   r8   )rA   	to_folderto_folder_idr   r   r   r   s          r   r   zFolder.copy_folder  s     $.i#@Ii 	 99DNN,nnOO.555H
 88==DHH_,E|+T=UT#7dD
 
,,
 ##V,
 	
r   )r   c                <   t        |t              r|j                  n|}| j                  s| j                  r|sy| j	                  | j
                  j                  d      j                  | j                              }| j                  j                  || j                  d      |i      }|sy|j                         }|j                  | j                  d      d      }|r;| j                  r/|| j                  k7  r || _        |r| j                         nd| _        y)	ai  Move this folder to another folder

        :param to_folder: the destination Folder/folder_id to move into
        :type to_folder: mailbox.Folder or str
        :param bool update_parent_if_changed: updates self.parent with the
         new parent Folder if changed
        :return: The new folder after copying
        :rtype: mailbox.Folder or None
        Fr   r   r   rz   r   NT)rR   r   r   r   r|   r}   r7   r   r%   r   r9   r   r   r   r$   )rA   r   r   r   r   r   r   r   s           r   r   zFolder.move_folder  s     $.i#@Ii 	 99DNN,nnOO.555H
 88==DHH_,E|+T=UJJtxx(894@	DNN*!*0HD**,d  r   c                     | j                  | d      }| j                  r!t        j                  j                  |_        |S | j
                  |_        |S )zlCreates a new draft message under this folder

        :return: new Message
        :rtype: Message
        T)r$   is_draft)r   r   r   DRAFTSr]   r   )rA   draft_messages     r   new_messagezFolder.new_message  sP     00t0L99&@&G&G&M&MM#  '+nnM#r   c                    t        |t              r|j                  n|}|t        d      | j	                  | j
                  j                  d      j                  |            }| j                  j                  |      }t        |      S )zDeletes a stored message

        :param message: message/message_id to delete
        :type message: Message or str
        :return: Success / Failure
        :rtype: bool
        z'Provide a valid Message or a message idr   r   )rR   r   r   r   r|   r}   r7   r   r%   r   r   )rA   r   
message_idr   r   s        r   delete_messagezFolder.delete_message  ss     +5Wg*FW&&G
HIInnT__00;BBjBQR88??3'H~r   rd   )NN)   )F)T)r   r   r   r   r}   r   r   r6   rK   rI   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   rk   s   @r   r   r      s    ' '9)$7//#	J "!%4 :$xL19td$ 9v)5e )5Z I "IVI6 '+ 5
n> "H*
B BF $L r   r   c                       e Zd ZdZeZeZddd fd
Zdde	j                  fdededej                  dej                  d	e	f
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! xZ"S )MailBoxzThe mailbox folder.Nr#   c                J    t        |   d||dd| d| j                  d<   y )NT)r$   r%   r   ro   rn   r   )r5   r6   r}   )rA   r$   r%   rB   rF   s       r   r6   zMailBox.__init__/  s*    ECdEfE&8
#r   internal_textexternal_textscheduled_start_date_timescheduled_end_date_timer+   c                     | j                         }|j                  }||_        t        j                  |_        |s|r#t        j                  |_        ||_        ||_        ||_	        ||_
        |j                         S )ziSet an automatic reply for the mailbox.

        :return: Success / Failure
        :rtype: bool
        )get_settingsru   rf   r   r   r1   r    rN   r_   r<   r;   r   )rA   r   r   r   r   r+   mailboxsettingsr   s           r   set_automatic_replyzMailBox.set_automatic_reply3  st     ++-66 0$22
$(?(22CJ*CC'(?C%%2"%2"##%%r   c                    t        |t        j                        st        d| d      t        |t        j                        s5t        j                  |j
                  |j                  |j                        }|j                  (|j                  | j                  j                        }|S |j                  | j                  j                  k7  r%|j                  | j                  j                        }|S )N'z& date' must be a valid datetime objectrP   )rR   rS   rT   r2   rU   rV   rW   rX   rQ   rY   r)   rZ   r[   )rA   r]   	erroritems      r   _validate_datetimezMailBox._validate_datetimeN  s    %)q+QRSS%-KK

EKKCE<<MM)?)?M@E  \\T]]333$$T]]%;%;<Er   c                     | j                         }|j                  }t        j                  |_        |j                         S )znDisable the automatic reply for the mailbox.

        :return: Success / Failure
        :rtype: bool
        )r   ru   r   r   r1   r   )rA   r   r   s      r   set_disable_replyzMailBox.set_disable_reply[  s9     ++-66$--
##%%r   c                 Z    | j                  | dt        j                  j                        S )zNShortcut to get Inbox Folder instance

        :rtype: mailbox.Folder
        Inboxr$   r   r   )r   r   INBOXr]   rJ   s    r   inbox_folderzMailBox.inbox_folderh  s0    
 &&g1K1Q1Q1W1W ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zMShortcut to get Junk Folder instance

        :rtype: mailbox.Folder
        Junkr  )r   r   JUNKr]   rJ   s    r   junk_folderzMailBox.junk_folderq  s0    
 &&f0J0O0O0U0U ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zUShortcut to get DeletedItems Folder instance

        :rtype: mailbox.Folder
        DeletedItemsr  )r   r   DELETEDr]   rJ   s    r   deleted_folderzMailBox.deleted_folderz  s1    
 &&088>> ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zOShortcut to get Drafts Folder instance

        :rtype: mailbox.Folder
        Draftsr  )r   r   r   r]   rJ   s    r   drafts_folderzMailBox.drafts_folder  1    
 &&077== ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zRShortcut to get SentItems Folder instance

        :rtype: mailbox.Folder
        	SentItemsr  )r   r   SENTr]   rJ   s    r   sent_folderzMailBox.sent_folder  s1    
 &&055;; ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zOShortcut to get Outbox Folder instance

        :rtype: mailbox.Folder
        Outboxr  )r   r   OUTBOXr]   rJ   s    r   outbox_folderzMailBox.outbox_folder  r  r   c                 Z    | j                  | dt        j                  j                        S )zPShortcut to get Archive Folder instance

        :rtype: mailbox.Folder
        Archiver  )r   r   ARCHIVEr]   rJ   s    r   archive_folderzMailBox.archive_folder  s1    
 &&088>> ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Clutter Folder instance
           The clutter folder low-priority messages are moved to when using the Clutter feature.
        
        :rtype: mailbox.Folder
        Clutterr  )r   r   CLUTTERr]   rJ   s    r   clutter_folderzMailBox.clutter_folder  s1     &&088>> ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Conflicts Folder instance
           The folder that contains conflicting items in the mailbox.
        
        :rtype: mailbox.Folder
        	Conflictsr  )r   r   	CONFLICTSr]   rJ   s    r   conflicts_folderzMailBox.conflicts_folder  1     &&0::@@ ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Conversation History Folder instance
           The folder where Skype saves IM conversations (if Skype is configured to do so).
        
        :rtype: mailbox.Folder
        r!  r  )r   r   CONVERSATIONHISTORYr]   rJ   s    r   conversationhistory_folderz"MailBox.conversationhistory_folder  s1     &&0DDJJ ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Local Failure Folder instance
        The folder that contains items that exist on the local client but could not be uploaded to the server.

        :rtype: mailbox.Folder
        zLocal Failuresr  )r   r   LOCALFAILURESr]   rJ   s    r   localfailures_folderzMailBox.localfailures_folder  1     &&!0>>DD ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )a  Shortcut to get Recoverable Items Deletions (Purges) Folder instance
        The folder that contains soft-deleted items: deleted either from the Deleted Items folder, or by pressing shift+delete in Outlook. 
        This folder is not visible in any Outlook email client, 
        but end users can interact with it through the Recover Deleted Items from Server feature in Outlook or Outlook on the web.

        :rtype: mailbox.Folder
        z$Recoverable Items Deletions (Purges)r  )r   r   RECOVERABLEITEMSDELETIONSr]   rJ   s    r    recoverableitemsdeletions_folderz(MailBox.recoverableitemsdeletions_folder  s1     &&70JJPP ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Scheduled Folder instance
        The folder that contains messages that are scheduled to reappear in the inbox using the Schedule feature in Outlook for iOS.
        
        :rtype: mailbox.Folder
        	Scheduledr  )r   r   r    r]   rJ   s    r   scheduled_folderzMailBox.scheduled_folder  r$  r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Search Folders Folder instance
        The parent folder for all search folders defined in the user's mailbox.
        
        :rtype: mailbox.Folder
        zSearch Foldersr  )r   r   SEARCHFOLDERSr]   rJ   s    r   searchfolders_folderzMailBox.searchfolders_folder  r+  r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Server Failures Folder instance
        The folder that contains items that exist on the server but could not be synchronized to the local client.
        
        :rtype: mailbox.Folder
        zServer Failuresr  )r   r   SERVERFAILURESr]   rJ   s    r   serverfailures_folderzMailBox.serverfailures_folder  s1     &&"0??EE ' 
 	
r   c                 Z    | j                  | dt        j                  j                        S )zShortcut to get Sync Issues Folder instance
        The folder that contains synchronization logs created by Outlook.
        
        :rtype: mailbox.Folder
        zSync Issuesr  )r   r   
SYNCISSUESr]   rJ   s    r   syncissues_folderzMailBox.syncissues_folder  s1     &&0;;AA ' 
 	
r   c                    | j                  | j                  j                  d            }i }| j                  j                  ||      }|st	        d      S |j                         } | j                  dd| i| j                  |iS )zEReturn the MailboxSettings.

        :rtype: mailboxsettings
        rn   r   r   r$   )r|   r}   r7   r%   r   r   mailbox_settings_constructorr8   )rA   r   r   r   r{   s        r   r   zMailBox.get_settings  s    
 nnT__00<=88<<F<38O}}0t00 

 00$7
 	
r   )#r   r   r   r   r   r   rm   r<  r6   r   r   r   rS   rU   r   r   r   r  r  r  r  r  r  r  r  r#  r'  r*  r.  r1  r4  r7  r:  r   rj   rk   s   @r   r   r   )  s    #2 !%4 9 26/3-=-A-A&& & $&;;	&
 "$& +&6&

	
	
	
	
	


















r   r   )rU   rS   loggingenumr   r   r   utilsr   r   r   r	   	getLoggerr   logr   r   r"   rm   r   r   r   r   r   <module>rB     s         g!t d J;| J;ZNl Nbh\ hVG
f G
r   