Skip to content

Commit

Permalink
List ID
Browse files Browse the repository at this point in the history
  • Loading branch information
justinh-rahb committed Aug 17, 2023
1 parent 17ebee8 commit d399ee8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api_integration.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -31,13 +31,15 @@ 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)

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)
3 changes: 3 additions & 0 deletions config.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit d399ee8

Please sign in to comment.