Skip to content

Commit

Permalink
⚡ ✨ feat: Add UID method to IMAPSearchCriteria for unique email ident…
Browse files Browse the repository at this point in the history
…ification

- 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.
  • Loading branch information
ARYAN-NIKNEZHAD committed Jul 24, 2024
1 parent df11fa5 commit a697e48
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sage_imap/helpers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,28 @@ def message_id(message_id: str) -> str:
>>> print(criteria) # Output: HEADER "Message-ID" "<[email protected]>"
"""
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}"

0 comments on commit a697e48

Please sign in to comment.