Skip to content

Commit

Permalink
Refactor optional test_access_token arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno committed Oct 31, 2023
1 parent 3962132 commit 6312c65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions hubmigrate/classes/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, config, hubspot, test_access_token=None):
self.config = config
self.hubspot = hubspot
self.base_path = 'https://api.hubapi.com/crm-associations/v1/associations'
self.headers = {"Authorization": f"Bearer { test_access_token if test_access_token else Auth.get_token() }"}
self.headers = {"Authorization": f"Bearer { Auth.get_token() }"}


def associate_records(cls, object1_id, object2_id, definition_id):
Expand All @@ -30,9 +30,7 @@ def associate_records(cls, object1_id, object2_id, definition_id):

response = requests.put(url, json=payload, headers=cls.headers)

status_codes = {200, 201, 202, 204}

if response.status_code in status_codes:
if response.status_code == 204:
print(f"Successfully associated records {object1_id} and {object2_id} 🎉")
else:
print(f"Error associating records {object1_id} and {object2_id}: {response.status_code} - {response.text} ❌")
Expand Down
2 changes: 1 addition & 1 deletion hubmigrate/classes/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, object_type, config, hubspot, test_access_token=None):
self.hubspot = hubspot
self.base_path = 'https://api.hubapi.com/crm/v3/objects'
self.path = f"{self.base_path}/{object_type}"
self.headers = {"Authorization": f"Bearer { test_access_token if test_access_token else Auth.get_token() }"}
self.headers = {"Authorization": f"Bearer { Auth.get_token() }"}

status_codes = {
200,
Expand Down

0 comments on commit 6312c65

Please sign in to comment.