From a697e485a55f6d6f4390db19bbe9e86a55d43fe9 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Wed, 24 Jul 2024 22:59:46 +0430 Subject: [PATCH] :zap: :sparkles: feat: Add UID method to IMAPSearchCriteria for unique email identification - Added static method to IMAPSearchCriteria class - The method generates search criteria for emails using the specified UID or range of UIDs - Updated class documentation with example usage for the method The method allows users to search for emails based on their unique identifiers, enhancing the search functionality of the IMAPSearchCriteria class. This update ensures better compatibility with the package for Python, providing a straightforward way to use UIDs in IMAP queries. --- sage_imap/helpers/search.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sage_imap/helpers/search.py b/sage_imap/helpers/search.py index e9faac8..866b175 100644 --- a/sage_imap/helpers/search.py +++ b/sage_imap/helpers/search.py @@ -348,3 +348,28 @@ def message_id(message_id: str) -> str: >>> print(criteria) # Output: HEADER "Message-ID" "" """ return f'HEADER "Message-ID" "{message_id}"' + + @staticmethod + def uid(uid: str) -> str: + """ + Generate search criteria for emails with the specified UID or range of UIDs. + + Parameters + ---------- + uid : str + The UID or range of UIDs. + + Returns + ------- + str + The constructed search criteria. + + Example + ------- + >>> criteria = IMAPSearchCriteria.uid("100") + >>> print(criteria) # Output: UID 100 + + >>> criteria = IMAPSearchCriteria.uid("100:200") + >>> print(criteria) # Output: UID 100:200 + """ + return f"UID {uid}"