From 462b19719f97367f08c8aebe0556681085c8c2f5 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Tue, 3 Oct 2023 09:45:17 -0700 Subject: [PATCH] region fallback --- recipes/QRCodeGenerator.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/recipes/QRCodeGenerator.py b/recipes/QRCodeGenerator.py index b97c82982..182f81006 100644 --- a/recipes/QRCodeGenerator.py +++ b/recipes/QRCodeGenerator.py @@ -776,11 +776,19 @@ def get_account_info_from_email(email: str): if photo_url and name and url and title and company and gender and notes: return photo_url, name, url, title, company, gender, notes - r = requests.get( - f"https://api.us-east-1-main.seon.io/SeonRestService/email-api/v2.2/{email}", - headers={"X-API-KEY": settings.SEON_API_KEY}, # type: ignore - ) - r.raise_for_status() + try: + r = requests.get( + f"https://api.seon.io/SeonRestService/email-api/v2.2/{email}", + headers={"X-API-KEY": settings.SEON_API_KEY}, # type: ignore + ) + r.raise_for_status() + except requests.exceptions.HTTPError: + ## region fallback for US devs + r = requests.get( + f"https://api.us-east-1-main.seon.io/SeonRestService/email-api/v2.2/{email}", + headers={"X-API-KEY": settings.SEON_API_KEY}, # type: ignore + ) + r.raise_for_status() account_details = glom.glom(r.json(), "data.account_details", default={}) for spec in [