U
    u|g                     @   s4   d dl Z d dlZd dlmZmZmZmZ dd ZdS )    N)dbinitialize_appcredentialsget_appc              
   C   s>  t d}zt|ddid}W n   td}Y nX ztd|| d}| }td| |dkrnW dS |d	}|d
d}|dks|dkrW dS ||d}	d}
|
dkrt	j
||	d}|jdkrW dS td|j d|j  |
d7 }
td|
d   qW n2 tk
r8 } ztd|  W 5 d}~X Y nX dS )z
    Handles webhook call. Will retry 4 times.

    :param uid:
    :param field_id:
    :param imagedate:
    :return: None
    zservicekey.jsondatabaseURLz,https://farmbase-b2f7e-741df.firebaseio.com/fireApp4ZSecureUserDatazwebhooks/satellitewebhook_objNurlversion   )FieldIDZ	SensedDay   )json   zError sending webhook: z -    )r   Certificater   r   r   	referencechildgetprintrequestspoststatus_codetexttimesleep	Exception)uidZfield_id	imagedatecredr   Zsat_webhook_refr   Zwebhook_urlZwebhook_versionobjattemptresponsee r$   1/home/ankuromar296_gmail_com/send_webhook_data.pysend_webhook_data   sP    





r&   )r   r   firebase_adminr   r   r   r   r&   r$   r$   r$   r%   <module>   s   