Work with Cvent API for IDAA members.

This commit is contained in:
Scott Idem
2022-02-04 18:15:39 -05:00
parent 7ca26ed325
commit 8d7063c116
2 changed files with 55 additions and 8 deletions

View File

@@ -31,6 +31,8 @@ async def process_recent_changes(
to_updated_on: datetime.datetime = None, # for Cvent "lastModified"
# type: str = 'created', # created, updated, created_updated
return_detail: bool = False,
commons: Common_Route_Params = Depends(common_route_params),
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
@@ -45,14 +47,20 @@ async def process_recent_changes(
to_updated_on = to_updated_on,
):
log.debug(cvent_contact_list_result)
cvent_contact_list = cvent_contact_list_result
log.info(f'Found {len(cvent_contact_list)} Cvent contacts')
else:
log.warning(f'Something went wrong while trying to get recently created or updated person in Cvent. From Datetime: {from_created_on}')
return mk_resp(data=None, status_code=400, response=commons.response) # Bad Request
# cvent_contact_list = cvent_contact_list_result.get('data')
# cvent_contact_list = cvent_contact_list_result
# return mk_resp(data=cvent_contact_list, status_message=f'Checked for recent changes in Cvent. Found {len(cvent_contact_list)} Cvent contacts', response=commons.response)
log.warning('Sleeping for 1.1 second to avoid Cvent rate limit...')
time.sleep(1.1)
cvent_contact_list = cvent_contact_list_result.get('data')
for cvent_person_contact_obj in cvent_contact_list:
cvent_person_contact_id = cvent_person_contact_obj.get('id')
log.info(f'Processing Cvent (Person) Contact ID: {cvent_person_contact_id}')
@@ -70,7 +78,10 @@ async def process_recent_changes(
log.warning('Sleeping for .5 second to avoid Cvent rate limit...')
time.sleep(.5)
return mk_resp(data=cvent_contact_list_result, status_message=f'Checked for recent changes in Cvent. Created/Updated {len(cvent_contact_list)} Cvent contacts', response=commons.response)
if return_detail:
return mk_resp(data=cvent_contact_list_result, status_message=f'Checked for recent changes in Cvent. Created/Updated {len(cvent_contact_list)} Cvent contacts', response=commons.response)
else:
return mk_resp(data=cvent_contact_list, status_message=f'Checked for recent changes in Cvent. Found {len(cvent_contact_list)} Cvent contacts', response=commons.response)
# ### END ### API Cvent ### process_recent_changes() ###