aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/mailersend/analytics
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/mailersend/analytics
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/mailersend/analytics')
-rw-r--r--.venv/lib/python3.12/site-packages/mailersend/analytics/__init__.py118
1 files changed, 118 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/mailersend/analytics/__init__.py b/.venv/lib/python3.12/site-packages/mailersend/analytics/__init__.py
new file mode 100644
index 00000000..cbc436c7
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/mailersend/analytics/__init__.py
@@ -0,0 +1,118 @@
+"""
+Handles /analytics endpoint
+Doc: https://developers.mailersend.com/api/v1/analytics.html
+"""
+
+import requests
+from mailersend.base import base
+
+
+class NewAnalytics(base.NewAPIClient):
+ """
+ Instantiates the /activity endpoint object
+ """
+
+ pass
+
+ def get_activity_by_date(
+ self, date_from, date_to, event, domain_id=None, group_by=None
+ ):
+ """
+ Returns a JSON response from the MailerSend API
+ """
+
+ _data = {
+ "date_from": date_from,
+ "date_to": date_to,
+ "event[]": event,
+ }
+
+ if domain_id is not None:
+ _data["domain_id"] = domain_id
+
+ if group_by is not None:
+ _data["group_by"] = group_by
+
+ request = requests.get(
+ f"{self.api_base}/analytics/date",
+ headers=self.headers_default,
+ params=_data,
+ )
+
+ return request.text
+
+ def get_opens_by_country(self, date_from, date_to, domain_id=None, recipients=None):
+ """
+ Returns a JSON response from the MailerSend API
+ """
+
+ _data = {
+ "date_from": date_from,
+ "date_to": date_to,
+ }
+
+ if domain_id is not None:
+ _data["domain_id"] = domain_id
+
+ if recipients is not None:
+ _data["recipient_id"] = recipients
+
+ request = requests.get(
+ f"{self.api_base}/analytics/country",
+ headers=self.headers_default,
+ json=_data,
+ )
+
+ return request.text
+
+ def get_opens_by_user_agent(
+ self, date_from, date_to, domain_id=None, recipients=None
+ ):
+ """
+ Returns a JSON response from the MailerSend API
+ """
+
+ _data = {
+ "date_from": date_from,
+ "date_to": date_to,
+ }
+
+ if domain_id is not None:
+ _data["domain_id"] = domain_id
+
+ if recipients is not None:
+ _data["recipient_id"] = recipients
+
+ request = requests.get(
+ f"{self.api_base}/analytics/ua-name",
+ headers=self.headers_default,
+ json=_data,
+ )
+
+ return request.text
+
+ def get_opens_by_reading_environment(
+ self, date_from, date_to, domain_id=None, recipients=None
+ ):
+ """
+ Returns a JSON response from the MailerSend API
+ """
+
+ _data = {
+ "date_from": date_from,
+ "date_to": date_to,
+ }
+
+ if domain_id is not None:
+ _data["domain_id"] = domain_id
+
+ if recipients is not None:
+ _data["recipient_id"] = recipients
+
+ request = requests.get(
+ f"{self.api_base}/analytics/ua-type",
+ headers=self.headers_default,
+ json=_data,
+ )
+
+ return request.text