aboutsummaryrefslogtreecommitdiff
path: root/jb/managers/email_manager.py
diff options
context:
space:
mode:
authorstuppie2026-09-23 15:07:47 -0600
committerstuppie2026-09-23 15:07:47 -0600
commit785adc51b2cc2b4d3e845a454f38b2a5197cc7f0 (patch)
treef7866bfb76e359f8078de4437f0f06e313847805 /jb/managers/email_manager.py
parent064a55c754e02da54b13c47028b233b265327518 (diff)
downloadamt-jb-785adc51b2cc2b4d3e845a454f38b2a5197cc7f0.tar.gz
amt-jb-785adc51b2cc2b4d3e845a454f38b2a5197cc7f0.zip
working on cashout postback, to be hit by thl upon cashout status change, which will send the user an email with the info
Diffstat (limited to 'jb/managers/email_manager.py')
-rw-r--r--jb/managers/email_manager.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/jb/managers/email_manager.py b/jb/managers/email_manager.py
index 8006844..08ac0cf 100644
--- a/jb/managers/email_manager.py
+++ b/jb/managers/email_manager.py
@@ -1,14 +1,19 @@
import requests
from generalresearch.config import is_debug
from generalresearch.currency import USDCent
-from generalresearch.models.thl.wallet.cashout_method import CashoutMethodOut
+from generalresearch.models.thl.wallet.cashout_method import (
+ CashoutMethodOut,
+ CashoutRequestInfo,
+)
from jb.config import settings
MAUTIC_BASE_URL = "https://mail.jamesbillings67.com"
LOGIN_EMAIL_TEMPLATE_ID = 1
# Todo: We need a new template for the cashout confirmation
-CASHOUT_EMAIL_TEMPLATE_ID = 3
+CASHOUT_REQUEST_EMAIL_TEMPLATE_ID = 3
+# Todo: We need a new template for the cashout status / sent
+CASHOUT_STATUS_EMAIL_TEMPLATE_ID = 4
assert settings.mautic_api_key
auth_headers = {"Authorization": f"Basic {settings.mautic_api_key.get_secret_value()}"}
@@ -72,7 +77,7 @@ def send_cashout_confirmation_email(
email: str, token: str, cashout_method: CashoutMethodOut, amount: USDCent
) -> None:
contact_id = get_or_create_contact(email=email)
- mautic_url = f"{MAUTIC_BASE_URL}/api/emails/{CASHOUT_EMAIL_TEMPLATE_ID}/contact/{contact_id}/send"
+ mautic_url = f"{MAUTIC_BASE_URL}/api/emails/{CASHOUT_REQUEST_EMAIL_TEMPLATE_ID}/contact/{contact_id}/send"
magic_link = f"{settings.base_url}wallet/cashout/confirm/?token={token}"
if is_debug():
print("MAGIC_LINK: ", magic_link)
@@ -87,3 +92,21 @@ def send_cashout_confirmation_email(
if cashout_method.image_url:
email_tokens["image_url"] = cashout_method.image_url
send_email_with_tokens(email_tokens, mautic_url)
+
+
+def send_cashout_status_email(email: str, cashout: CashoutRequestInfo) -> None:
+ assert cashout.status is not None
+ email_tokens = {
+ "cashout_id": str(cashout.id),
+ "cashout_status": cashout.status.value,
+ }
+ # todo: (if tango) format credentials and redemption instructions
+ # "credentials": "",
+ # "redemption_instructions": "",
+
+ if is_debug():
+ print("CASHOUT_STATUS_EMAIL: ", email_tokens)
+ return
+ contact_id = get_or_create_contact(email=email)
+ mautic_url = f"{MAUTIC_BASE_URL}/api/emails/{CASHOUT_STATUS_EMAIL_TEMPLATE_ID}/contact/{contact_id}/send"
+ send_email_with_tokens(email_tokens, mautic_url)