Spaces:
Running
Running
Update get_gmail_data.py
Browse files- 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=
|
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:
|