o
    {V
h                     @   s&   d dl Z d dlmZ G dd dZdS )    N)get_mongo_dbc                   @   s$   e Zd Zdd Zdd Zdd ZdS )SalesforceIntegrationc                 C   s   || _ |  | _d S )N)
account_id
get_configconfig)selfr    r   :/var/www/html/moveengine/app/v1/integrations/salesforce.py__init__   s   zSalesforceIntegration.__init__c                 C   s*   t  }|j| jdd}|std|S )N
salesforce)r   integration_namez2Salesforce integration not found for this account.)r   marketplace_integrationsfind_oner   	Exception)r   dbr   r   r   r	   r      s   z SalesforceIntegration.get_configc                 C   sR   | j d d  d| j d d  d}d| j d  dd	}tj|||d
}| S )Nother_configinstance_urlz/services/data/versionz/sobjects/Lead/zBearer api_keyzapplication/json)AuthorizationzContent-Type)headersjson)r   requestspostr   )r   dataurlr   responser   r   r	   create_lead   s   $z!SalesforceIntegration.create_leadN)__name__
__module____qualname__r
   r   r   r   r   r   r	   r      s    
r   )r   app.db.databaser   r   r   r   r   r	   <module>   s   