From af7edafd35a872ca7f0ca2e69cc00b050b1ffcaf Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Fri, 28 Jul 2023 17:22:48 -0400 Subject: [PATCH] Started the Hubspot script for Tracy... super confusing. Added a few notes and template items. --- .../TripleSeat/auth_url_terms.html.liquid | 11 ++-- Scripts/API_Tests/hubspot_notes.py | 66 +++++++++++++++++++ Scripts/Todo_reorg/parse_for_gstimeline.py | 19 ++++-- 3 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 Scripts/API_Tests/hubspot_notes.py diff --git a/Custom_Templates/customer_templates/TripleSeat/auth_url_terms.html.liquid b/Custom_Templates/customer_templates/TripleSeat/auth_url_terms.html.liquid index a7087db2..590b4cce 100644 --- a/Custom_Templates/customer_templates/TripleSeat/auth_url_terms.html.liquid +++ b/Custom_Templates/customer_templates/TripleSeat/auth_url_terms.html.liquid @@ -4,11 +4,13 @@
{% t shared.welcome_to_school, school_name: current_school.name %}
-
{% t .headline, key: current_school.course_vocabulary %}
+
+ To access your courses enter the email address you will use with Tripleseat, first name, and last name below. +
{% form_authenticity_token %}
-
+ {% comment %}
@@ -54,7 +56,8 @@ id="learner_phone_number" value="{{ form.phone_number }}" /> -
+
+ {% endcomment %}
diff --git a/Scripts/API_Tests/hubspot_notes.py b/Scripts/API_Tests/hubspot_notes.py new file mode 100644 index 00000000..48164fb2 --- /dev/null +++ b/Scripts/API_Tests/hubspot_notes.py @@ -0,0 +1,66 @@ +import requests +import json +import hubspot +from pprint import pprint +from hubspot.crm.objects.notes import ApiException + + +def no_client(): + COMPANYID = "5951571334" + headers = { + "Authorization": "Bearer pat-na1-9f41f073-95e2-4eea-b0c9-3e9571a3998c", + } + # url = "https://api.hubapi.com/crm/v3/objects/companies?limit=10&archived=false" + # url = "https://api.hubapi.com/crm/v3/objects/notes?limit=100&archived=false&properties=hubspot_owner_id,hs_note_body" + # url = f"https://api.hubapi.com/crm/v4/objects/companies/{COMPANYID}/associations/notes" + url = f"https://api.hubapi.com/engagements/v1/engagements/" # 36317682030" + # associated/COMPANY/{COMPANYID}" + + response = requests.get(url, headers=headers) + jsontext = response.json() + print(jsontext) + # for item in jsontext['results']: + # for props in item['properties']: + # if item['properties']['hubspot_owner_id'] == '2757824': + # print(item) + + # props = json.dumps(props, indent=2) + + # formatted = json.dumps(jsontext, indent=2) + # print(jsontext) + # for item in jsontext['results']: + # if item['engagement']['type'] == 'NOTE': + # # pass + # print(item) + # if item['engagement']['type'] == 'NOTE': + + +def hubspot_client(): + client = hubspot.Client.create( + access_token="pat-na1-9f41f073-95e2-4eea-b0c9-3e9571a3998c" + ) + + # try: + # api_response = client.crm.objects.notes.basic_api.get_page( + # limit=10, properties=['hs_note_body', 'id'], + # associations=['Company'], archived=False + # ) + # pprint(api_response) + # except ApiException as e: + # print("Exception when calling basic_api->get_page: %s\n" % e) + + try: + api_response = client.crm.objects.notes.basic_api.get_page( + archived=False, properties=["hs_note_body", "hubspot_owner_id", "id"] + ) + api = api_response.to_dict() + print(type(api)) + + # pprint(api_response) + except ApiException as e: + print("Exception when calling basic_api->get_by_id: %s\n" % e) + + +if __name__ == "__main__": + no_client() + # hubspot_client() diff --git a/Scripts/Todo_reorg/parse_for_gstimeline.py b/Scripts/Todo_reorg/parse_for_gstimeline.py index 41f15c16..f43e1043 100644 --- a/Scripts/Todo_reorg/parse_for_gstimeline.py +++ b/Scripts/Todo_reorg/parse_for_gstimeline.py @@ -5,22 +5,31 @@ import itertools ndir = Path("/Users/normrasmussen/Documents/Work/CustomerNotes/") + def get_files(): - list_of_lists = [] merge = pd.DataFrame() - merge3 = pd.DataFrame() - merged = pd.DataFrame() + dict_copy = pd.DataFrame() + empty_temp = pd.DataFrame() files = list(ndir.glob("**/*.md")) for company in files: # This Section gets the Company name for the payload. company = str(company) company_file = company.split("/")[-1] company_name = company_file[:-3] - # if company_name == "Bolt": + list_of_dicts = get_data(company_file, company_name) + # This returns a list of dictionaries - one list per company + dic = pd.DataFrame.from_records(list_of_dicts) + # This gets overwritten for each list out put by the function. + # So once a list comes out, it needs to be copied. + dict_copy = dic.copy() - merge = pd.concat([dict_copy, merge], ignore_index=True) + # Now that it is copied.. merge it here first? + + empty_temp = pd.concat([dict_copy, empty_temp], ignore_index=True) + merge = pd.concat([empty_temp, merge], ignore_index=True) + merge.to_csv("/Users/normrasmussen/Downloads/Notes_for_GS.csv") print(merge)