Omkar008 commited on
Commit
47ec489
1 Parent(s): 09cc3e4

Update get_gmail_data.py

Browse files
Files changed (1) hide show
  1. get_gmail_data.py +3 -2
get_gmail_data.py CHANGED
@@ -56,7 +56,7 @@ class GmailDataExtractor:
56
  receipt_query = f'(subject:"your order" OR subject:receipts OR subject:receipt OR subject: aankoopbon OR subject:reçu OR subject:invoice OR subject:invoice OR category:purchases)'
57
  # if self.__user_input is not None:
58
  # receipt_query = f'((subject:"your order" OR subject:receipts OR subject:receipt OR subject:invoice OR subject:invoice OR category:purchases) AND subject:{self.__user_input})&maxResults=15'
59
- gmail_url = f"https://www.googleapis.com/gmail/v1/users/me/messages?q={receipt_query}&maxResults=10"
60
  def __fetch_page(url):
61
  response = requests.get(url, headers={"Authorization": f"Bearer {access_token}"})
62
  response.raise_for_status() # Raise error if the request fails
@@ -74,7 +74,8 @@ class GmailDataExtractor:
74
  break
75
  except requests.RequestException as e:
76
  raise RuntimeError(f"Error fetching messages from Gmail API: {str(e)}")
77
-
 
78
  return messages
79
 
80
  def __fetch_message_data(self, message_id: str) -> dict:
 
56
  receipt_query = f'(subject:"your order" OR subject:receipts OR subject:receipt OR subject: aankoopbon OR subject:reçu OR subject:invoice OR subject:invoice OR category:purchases)'
57
  # if self.__user_input is not None:
58
  # receipt_query = f'((subject:"your order" OR subject:receipts OR subject:receipt OR subject:invoice OR subject:invoice OR category:purchases) AND subject:{self.__user_input})&maxResults=15'
59
+ gmail_url = f"https://www.googleapis.com/gmail/v1/users/me/messages?q={receipt_query}&maxResults=5"
60
  def __fetch_page(url):
61
  response = requests.get(url, headers={"Authorization": f"Bearer {access_token}"})
62
  response.raise_for_status() # Raise error if the request fails
 
74
  break
75
  except requests.RequestException as e:
76
  raise RuntimeError(f"Error fetching messages from Gmail API: {str(e)}")
77
+
78
+ print(len(messages))
79
  return messages
80
 
81
  def __fetch_message_data(self, message_id: str) -> dict: