From d399ee89e5bf0dc58f2d441922200dcd7282caf3 Mon Sep 17 00:00:00 2001 From: Justin Hayes Date: Thu, 17 Aug 2023 14:24:59 -0400 Subject: [PATCH] List ID --- api_integration.py | 4 +++- config.example.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api_integration.py b/api_integration.py index cd89e34..058f659 100644 --- a/api_integration.py +++ b/api_integration.py @@ -1,5 +1,5 @@ import requests -from config import JSON_URL, BASE_URL +from config import JSON_URL, BASE_URL, LIST_ID HEADERS = { "Content-Type": "application/json" @@ -31,6 +31,7 @@ def contact_exists_in_cc(email, token): def create_contact_in_cc(contact, token): headers = {**HEADERS, **get_auth_header(token)} url = f"{BASE_URL}/contacts" + contact["lists"] = [{"id": LIST_ID}] response = requests.post(url, json=contact, headers=headers) if response.status_code != 201: print(f"Error {response.status_code} creating contact in CC: ", response.text) @@ -38,6 +39,7 @@ def create_contact_in_cc(contact, token): def update_contact_in_cc(contact_id, contact, token): headers = {**HEADERS, **get_auth_header(token)} url = f"{BASE_URL}/contacts/{contact_id}" + contact["lists"] = [{"id": LIST_ID}] response = requests.put(url, json=contact, headers=headers) if response.status_code != 204: print(f"Error {response.status_code} updating contact in CC: ", response.text) diff --git a/config.example.py b/config.example.py index 6caf00f..f869ad6 100644 --- a/config.example.py +++ b/config.example.py @@ -4,6 +4,9 @@ # Constant Contact API Base URL BASE_URL = "https://api.cc.email/v3" +# List ID for Constant Contact +LIST_ID = "YOUR_LIST_ID_HERE" + # OAuth2 Constants CLIENT_ID = 'YOUR_CLIENT_ID' CLIENT_SECRET = 'YOUR_CLIENT_SECRET'