(list_of_emails, retry_num=0, record_metrics=True)
return {}
Gets a list of Contacts on Hubspot from a list of emails.
    If an email in the list doesn't exist on Hubspot, it's simply ignored.
    :param list_of_emails:
    :param retry_num: the number of the current retry attempt
    :param record_metrics: whether metrics should be sent to datadog
    :return: HubSpot contacts as dict
Gets a list of Contacts on Hubspot from a list of emails.
    If an email in the list doesn't exist on Hubspot, it's simply ignored.
    :param list_of_emails:
    :param retry_num: the number of the current retry attempt
    :param record_metrics: whether metrics should be sent to datadog
    :return: HubSpot contacts as dict
Gets a list of Contacts on Hubspot from a list of emails . If an email in the list doesn t exist on Hubspot it s simply ignored . : param list_of_emails : : param retry_num : the number of the current retry attempt : param record_metrics : whether metrics should be sent to datadog : return : HubSpot contacts as dict
def _get_contacts_from_hubspot(list_of_emails, retry_num=0, record_metrics=True):
    """
    Gets a list of Contacts on Hubspot from a list of emails.
    If an email in the list doesn't exist on Hubspot, it's simply ignored.
    :param list_of_emails:
    :param retry_num: the number of the current retry attempt
    :param record_metrics: whether metrics should be sent to datadog
    :return: HubSpot contacts as dict
    """
    if retry_num > 0:
        time.sleep(10)  # wait 10 seconds if this is another retry attempt

    api_key = settings.ANALYTICS_IDS.get('HUBSPOT_API_KEY', None)
    if api_key:
        try:
            req = requests.get(
                "https://api.hubapi.com/contacts/v1/contact/emails/batch/",
                params={
                    'hapikey': api_key,
                    'email': list_of_emails,
                },
            )
            if req.status_code == 404:
                return []
            req.raise_for_status()
        except (ConnectionError, requests.exceptions.HTTPError) as e:
            if record_metrics:
                metrics_counter(
                    'commcare.hubspot_data.retry.get_contact_ids_for_emails'
                )
            if retry_num <= MAX_API_RETRIES:
                return _get_contacts_from_hubspot(list_of_emails, retry_num + 1)
            elif record_metrics:
                metrics_counter(
                    'commcare.hubspot_data.error.get_contact_ids_for_emails',
                    tags={
                        'error': str(e),
                    }
                )
        else:
            return req.json()
    return {}
def _get_contacts_from_hubspot ( list_of_emails , retry_num = 0 , record_metrics = True ) : if retry_num > 0 : time . sleep ( 10 ) # wait 10 seconds if this is another retry attempt api_key = settings . ANALYTICS_IDS . get ( 'HUBSPOT_API_KEY' , None ) if api_key : try : req = requests . get ( "https://api.hubapi.com/contacts/v1/contact/emails/batch/" , params = { 'hapikey' : api_key , 'email' : list_of_emails , } , ) if req . status_code == 404 : return [ ] req . raise_for_status ( ) except ( ConnectionError , requests . exceptions . HTTPError ) as e : if record_metrics : metrics_counter ( 'commcare.hubspot_data.retry.get_contact_ids_for_emails' ) if retry_num <= MAX_API_RETRIES : return _get_contacts_from_hubspot ( list_of_emails , retry_num + 1 ) elif record_metrics : metrics_counter ( 'commcare.hubspot_data.error.get_contact_ids_for_emails' , tags = { 'error' : str ( e ) , } ) else : return req . json ( ) return { }