#!/usr/bin/env python3 """Create 'How we check' methodology campaign and update campaign 111.""" import json import urllib.request import base64 AUTH = base64.b64encode(b"api:6X1rKPea61N4rZ1S65Hx5zvqzbCj30F6nvEe9oVGH_Y").decode() API = "http://localhost:9100/api" BODY = """
""" # 1. Create methodology campaign for existing recipients (List 11) data1 = { "name": "How we check — we read your actual filed document", "subject": "How we check your FCC compliance (and why results may differ from your filing agent)", "from_email": "Performance West ", "content_type": "html", "body": BODY, "lists": [11], "template_id": 1, "headers": [{"Reply-To": "info@performancewest.net"}], "tags": ["methodology", "transparency"], } req1 = urllib.request.Request(API + "/campaigns", data=json.dumps(data1).encode(), method="POST", headers={"Content-Type": "application/json", "Authorization": "Basic " + AUTH}) resp1 = json.loads(urllib.request.urlopen(req1).read()) cid1 = resp1.get("data", {}).get("id") print(f"Campaign {cid1}: Methodology email → List 11 (1,261 existing)") # Start it req_s = urllib.request.Request(API + f"/campaigns/{cid1}/status", data=json.dumps({"status": "running"}).encode(), method="PUT", headers={"Content-Type": "application/json", "Authorization": "Basic " + AUTH}) urllib.request.urlopen(req_s) print(f"Campaign {cid1} STARTED — sending to 1,261 recipients") # 2. Update campaign 111 body for remaining ~1,457 recipients print("\nUpdating campaign 111 body for future recipients...") import psycopg2 import os conn = psycopg2.connect(os.environ.get("DATABASE_URL", "")) cur = conn.cursor() cur.execute("UPDATE campaigns SET body = %s WHERE id = 111", (BODY,)) conn.commit() cur.close() conn.close() print("Campaign 111 body updated — remaining recipients will get the methodology version")