#!/usr/bin/env python3
"""Test access to all Google Ads accounts with MCC."""

import sys
sys.path.insert(0, '/Users/dominiquezhoumacmini/Library/Python/3.9/lib/python/site-packages')

from google.ads.googleads.client import GoogleAdsClient

ACCOUNTS = [
    ("Elde Ventures LLC - US (NEW)", "2949069258"),
    ("ZEDE PARIS - US (OLD)", "7480586470"),
    ("Zede Paris FR/EU", "7441745274"),
]

def test_account(client, name, customer_id):
    ga_service = client.get_service("GoogleAdsService")
    
    query = """
        SELECT customer.id, customer.descriptive_name,
               metrics.cost_micros, metrics.conversions
        FROM customer
        WHERE segments.date DURING LAST_30_DAYS
    """
    
    print(f"\n{name} ({customer_id})")
    
    try:
        response = ga_service.search(customer_id=customer_id, query=query)
        for row in response:
            cost = row.metrics.cost_micros / 1_000_000
            conv = row.metrics.conversions
            print(f"  ✅ Connected | 30d: ${cost:,.0f} spent, {conv:.0f} conversions")
        return True
    except Exception as e:
        if "USER_PERMISSION_DENIED" in str(e):
            print(f"  ❌ Permission denied")
        else:
            print(f"  ❌ Error: {str(e)[:80]}")
        return False

def main():
    client = GoogleAdsClient.load_from_storage("/Users/dominiquezhoumacmini/.google-ads.yaml")
    
    print("Testing all accounts with MCC 220-793-5454...\n")
    
    for name, cid in ACCOUNTS:
        test_account(client, name, cid)

if __name__ == "__main__":
    main()
