Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resultSizeEstimate property #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions simplegmail/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
) -> None:
self.client_secret_file = client_secret_file
self.creds_file = creds_file
self._resultSizeEstimate = 0

try:
# The file gmail_token.json stores the user's access and refresh
Expand Down Expand Up @@ -516,6 +517,9 @@ def get_messages(
includeSpamTrash=include_spam_trash
).execute()

if 'resultSizeEstimate' in response:
self._resultSizeEstimate = response['resultSizeEstimate']

message_refs = []
if 'messages' in response: # ensure request was successful
message_refs.extend(response['messages'])
Expand All @@ -530,6 +534,9 @@ def get_messages(
pageToken=page_token
).execute()

if 'resultSizeEstimate' in response:
self._resultSizeEstimate = response['resultSizeEstimate']

message_refs.extend(response['messages'])

return self._get_messages_from_refs(user_id, message_refs,
Expand Down Expand Up @@ -988,3 +995,7 @@ def _get_alias_info(

res = req.execute()
return res

@property
def resultSizeEstimate(self):
return self._resultSizeEstimate