(vid, retry_num=0)
return False
Permanently deletes a Hubspot contact.
    :param vid:  (the contact ID)
    :param retry_num: the number of the current retry attempt
    :return: boolean if contact was deleted
Permanently deletes a Hubspot contact.
    :param vid:  (the contact ID)
    :param retry_num: the number of the current retry attempt
    :return: boolean if contact was deleted
Permanently deletes a Hubspot contact . : param vid : ( the contact ID ) : param retry_num : the number of the current retry attempt : return : boolean if contact was deleted
def _delete_hubspot_contact(vid, retry_num=0):
    """
    Permanently deletes a Hubspot contact.
    :param vid:  (the contact ID)
    :param retry_num: the number of the current retry attempt
    :return: boolean if contact was deleted
    """
    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.delete(
                f'https://api.hubapi.com/contacts/v1/contact/vid/{vid}',
                params={
                    'hapikey': api_key,
                }
            )
            if req.status_code == 404:
                return False
            req.raise_for_status()
        except (ConnectionError, requests.exceptions.HTTPError) as e:
            metrics_counter(
                'commcare.hubspot_data.retry.delete_hubspot_contact'
            )
            if retry_num <= MAX_API_RETRIES:
                return _delete_hubspot_contact(vid, retry_num + 1)
            else:
                metrics_counter(
                    'commcare.hubspot_data.error.delete_hubspot_contact',
                    tags={
                        'error': str(e),
                    }
                )
        else:
            return True
    return False
def _delete_hubspot_contact ( vid , retry_num = 0 ) : 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 . delete ( f'https://api.hubapi.com/contacts/v1/contact/vid/{vid}' , params = { 'hapikey' : api_key , } ) if req . status_code == 404 : return False req . raise_for_status ( ) except ( ConnectionError , requests . exceptions . HTTPError ) as e : metrics_counter ( 'commcare.hubspot_data.retry.delete_hubspot_contact' ) if retry_num <= MAX_API_RETRIES : return _delete_hubspot_contact ( vid , retry_num + 1 ) else : metrics_counter ( 'commcare.hubspot_data.error.delete_hubspot_contact' , tags = { 'error' : str ( e ) , } ) else : return True return False