Work on exhibit tracking
This commit is contained in:
@@ -270,6 +270,73 @@ def get_event_registrants(
|
||||
# ### END ### API Impexium Methods ### get_event_registrants() ###
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API External Impexium Methods ### get_individual_profile() ###
|
||||
# Updated 2022-04-22
|
||||
@logger_reset
|
||||
def get_individual_profile(
|
||||
individual_id: str,
|
||||
details: bool = False,
|
||||
page = 1 # page: int = 0,
|
||||
):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if result := authenticate():
|
||||
log.debug(result)
|
||||
else:
|
||||
return False
|
||||
|
||||
endpoint = f'/Individuals/Profile/{individual_id}/{page}'
|
||||
uri = api['base_url']+endpoint
|
||||
params = { 'IncludeDetails': details }
|
||||
|
||||
impexium_individual_profile = None
|
||||
|
||||
try_request = True
|
||||
max_tries = 5
|
||||
try_count = 0
|
||||
while try_request and try_count <= max_tries:
|
||||
try_count = try_count + 1
|
||||
|
||||
resp = requests.get(url=uri, params=params, headers=api['headers'])
|
||||
|
||||
log.debug(f'Status Code: {resp.status_code}')
|
||||
log.debug(f'Headers: {resp.headers}')
|
||||
# log.debug(f'Encoding: {resp.encoding}')
|
||||
# log.debug('Text:')
|
||||
# log.debug(resp.text)
|
||||
# log.debug(resp.json())
|
||||
|
||||
if resp.status_code == 200:
|
||||
log.debug(resp.json())
|
||||
|
||||
impexium_individual_profile_raw = resp.json() # .get('data').get('dataList')[0]
|
||||
# log.debug(impexium_individual_profile_raw)
|
||||
|
||||
impexium_individual_profile = impexium_individual_profile_raw.get('dataList')[0]
|
||||
log.debug(impexium_individual_profile)
|
||||
|
||||
try_request = False
|
||||
elif resp.status_code == 404:
|
||||
log.info('No results returned.')
|
||||
try_request = False
|
||||
impexium_individual_profile = None
|
||||
elif resp.status_code == 429:
|
||||
log.warning('Hit rate limit. Sleeping for .1 seconds...')
|
||||
time.sleep(.1)
|
||||
try_request = True
|
||||
impexium_individual_profile = False
|
||||
else:
|
||||
try_request = False
|
||||
impexium_event_registration_list = False
|
||||
|
||||
return impexium_individual_profile
|
||||
# ### END ### API External Impexium Methods ### get_individual_profile() ###
|
||||
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API External Impexium Methods ### get_individual_registrations() ###
|
||||
# Updated 2022-02-18
|
||||
@logger_reset
|
||||
|
||||
Reference in New Issue
Block a user