Started the Hubspot script for Tracy... super confusing. Added a few notes and template items.

This commit is contained in:
Norm Rasmussen
2023-07-28 17:22:48 -04:00
parent 79794e0030
commit af7edafd35
3 changed files with 87 additions and 9 deletions

View File

@ -4,11 +4,13 @@
<div class="np-box-content-container">
<form class="np-form np-box-content" action="{{ form.url }}" method="get" novalidate>
<div class="np-form-headline"> {% t shared.welcome_to_school, school_name: current_school.name %} </div>
<div class="np-form-subheadline"> {% t .headline, key: current_school.course_vocabulary %} </div>
<div class="np-form-subheadline">
To access your courses enter the email address you will use with Tripleseat, first name, and last name below.
</div>
{% form_authenticity_token %}
<div class="np-form-field">
<label class="np-input-label" for="learner_email">
{% t shared.email_address %}
Work Email Address
</label>
<input
class="np-input"
@ -43,7 +45,7 @@
value="{{ form.last_name }}"
/>
</div>
<div class="np-form-field">
{% comment %} <div class="np-form-field">
<label class="np-input-label" for="learner_phone_number">
{% t shared.phone_number_optional %}
</label>
@ -54,7 +56,8 @@
id="learner_phone_number"
value="{{ form.phone_number }}"
/>
</div>
</div>
{% endcomment %}
<div class="np-form-field np-open-access-terms">
<input type="hidden" name="terms" value="0" />
<input id="terms" type="checkbox" name="terms" value="1" />

View File

@ -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()

View File

@ -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)