Cleaning up create and update Cvent person in Aether for IDAA members.
This commit is contained in:
@@ -9,7 +9,7 @@ from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select,
|
||||
|
||||
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||
|
||||
from app.methods.e_cvent_methods import get_access_token, get_contact_custom_field_list, get_contact_list, get_contact_id, modify_contact_id
|
||||
from app.methods.e_cvent_methods import create_update_aether_person, get_access_token, get_contact_custom_field_list, get_contact_list, get_contact_id, modify_contact_id
|
||||
from app.methods.person_methods import create_person_kiss, get_person_rec_list, get_person_rec_w_external_id, load_person_obj, update_person_kiss
|
||||
from app.methods.membership_person_methods import create_membership_person_obj, update_membership_person_obj
|
||||
|
||||
@@ -22,9 +22,9 @@ router = APIRouter()
|
||||
|
||||
# ### BEGIN ### API Cvent ### get_person() ###
|
||||
# Updated 2022-02-01
|
||||
@router.get('/person/{e_person_id}', response_model=Resp_Body_Base)
|
||||
@router.get('/person/{cvent_person_id}', response_model=Resp_Body_Base)
|
||||
async def get_person(
|
||||
e_person_id: str = Query(..., min_length=36, max_length=36), # UUID v4; actually the Cvent Contact UUID for a person
|
||||
cvent_person_id: str = Query(..., min_length=36, max_length=36), # UUID v4; actually the Cvent Contact UUID for a person
|
||||
person_id: str = Query(None, min_length=11, max_length=22),
|
||||
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
@@ -51,10 +51,10 @@ async def get_person(
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
# ### SECTION ### Get the Cvent Contact with the Cvent UUID.
|
||||
if cvent_contact_obj_result := get_contact_id(contact_id=e_person_id):
|
||||
if cvent_contact_obj_result := get_contact_id(contact_id=cvent_person_id):
|
||||
cvent_contact_obj = cvent_contact_obj_result
|
||||
else:
|
||||
log.info(f'Cvent contact not found with ID: {e_person_id}')
|
||||
log.info(f'Cvent contact not found with ID: {cvent_person_id}')
|
||||
return mk_resp(data=None, status_code=404, response=commons.response) # Not Found
|
||||
|
||||
# cvent_contact_obj = {'id': '59B1642A-E193-4B47-910B-566029C44620', 'firstName': 'Nicholas', 'lastName': 'Kasnick', 'email': 'kasnick6412@gmail.com', 'homePhone': '3603494072', 'homeAddress': {'address1': '14924 89th ave', 'city': 'Yelm', 'postalCode': '98597', 'country': 'USA', 'countryCode': 'US'}, 'sourceId': '00293862', 'deleted': False, 'type': {'id': '03622AEE-F586-4AE5-A191-B8372543A8C8', 'name': 'Student Member'}, 'created': '2022-01-25T02:43:17.157Z', 'lastModified': '2022-01-26T16:07:43.505Z', 'createdBy': 'kasnick6412@gmail.com', 'lastModifiedBy': 'kasnick6412@gmail.com', 'optOut': {'optedOut': False, 'by': 'Cvent Support'}, 'membership': {'joined': '2022-01-24', 'expiration': '2023-01-24'}, 'customFields': [{'id': 'e46d8043-705b-4315-9611-6fba9211b2e2', 'name': 'Non-Binary Gender', 'value': ['Male'], 'type': 'SingleSelect', 'order': 2}, {'id': '656b419b-d974-49a7-85df-cda564a7a06e', 'name': 'Qualifying Degree', 'value': ['Student, Qualifying Healthcare Professional'], 'type': 'SingleSelect', 'order': 3}, {'id': '1ef02428-59a1-493a-8535-407ed5d65f6f', 'name': 'Practice Status', 'value': ['In Training'], 'type': 'SingleSelect', 'order': 5}, {'id': 'c1b47d46-d219-4f1a-a8f9-8030c7f55f31', 'name': 'Recovery Programs', 'value': ['AA', 'Al-Anon'], 'type': 'MultiSelect', 'order': 7}, {'id': '84210a3a-43c9-491d-badf-fd5bb19151b7', 'name': 'Paper Mail Opted Out', 'value': ['Yes'], 'type': 'SingleSelect', 'order': 17}, {'id': '3b91172f-3cde-4ffc-822e-6bcc80a1eda7', 'name': 'I am joining IDAA as a', 'value': ['Medical member with a qualifying degree'], 'type': 'SingleSelect', 'order': 21}, {'id': '2245946b-2634-4044-8ad5-3cd897424f32', 'name': 'Sobriety Date', 'value': ['2022-01-08T00:00'], 'type': 'Date', 'order': 22}]}
|
||||
@@ -68,16 +68,29 @@ async def get_person(
|
||||
|
||||
# Important variables used more than once.
|
||||
account_id = commons.x_account_id
|
||||
person_external_id = None
|
||||
if custom_field_list := cvent_contact_obj.get('customFields'): # List
|
||||
for custom_field in custom_field_list:
|
||||
# Get the External ID created by OSIT
|
||||
if custom_field.get('id') == '609ab766-7d79-4a9d-a72c-f126412659ee':
|
||||
# person_data['external_id'] = custom_field.get('value')[0]
|
||||
person_external_id = custom_field.get('value')[0]
|
||||
email = cvent_contact_obj.get('email')
|
||||
membership_person_id = None
|
||||
membership_person_type_id = None
|
||||
# person_external_id = None
|
||||
# if custom_field_list := cvent_contact_obj.get('customFields'): # List
|
||||
# for custom_field in custom_field_list:
|
||||
# # Get the External ID created by OSIT
|
||||
# if custom_field.get('id') == '609ab766-7d79-4a9d-a72c-f126412659ee':
|
||||
# # person_data['external_id'] = custom_field.get('value')[0]
|
||||
# person_external_id = custom_field.get('value')[0]
|
||||
# email = cvent_contact_obj.get('email')
|
||||
# membership_person_id = None
|
||||
# membership_person_type_id = None
|
||||
|
||||
if create_update_aether_person_result := create_update_aether_person(
|
||||
cvent_contact_id = cvent_person_id,
|
||||
cvent_contact_obj = cvent_contact_obj,
|
||||
account_id = account_id,
|
||||
person_id = person_id
|
||||
):
|
||||
person_obj = create_update_aether_person_result
|
||||
return mk_resp(data=person_obj, status_message='Created/Updated and loaded person based on Cvent contact information', response=commons.response)
|
||||
else:
|
||||
log.info(f'Something went wrong while trying to create or update the person in Aether based on Cvent data. Cvent (Person) Contact ID: {cvent_person_id}')
|
||||
return mk_resp(data=None, status_code=400, response=commons.response) # Bad Request
|
||||
|
||||
|
||||
# Important contact fields:
|
||||
# id (UUID v4)
|
||||
@@ -296,7 +309,7 @@ async def get_person(
|
||||
time.sleep(1)
|
||||
|
||||
contact_mod_result = modify_contact_id(
|
||||
contact_id = e_person_id, # This is the Cvent Contact UUID for a person
|
||||
contact_id = cvent_person_id, # This is the Cvent Contact UUID for a person
|
||||
# field_list = field_list,
|
||||
custom_field_id = custom_field_id,
|
||||
custom_field_value = custom_field_value,
|
||||
|
||||
Reference in New Issue
Block a user