o
    w+f                     @   s   d Z ddlZddlZddlmZ zddlmZ W n ey'   ddlmZ Y nw ddl	m
Z
 G dd deZdd	 Zed
krCe  dS dS )zoA module for sending test SendGrid Inbound Parse messages.
Usage: ./send.py [path to file containing test data]    N)open)Config)Clientc                   @   s(   e Zd Zdd Zdd Zedd ZdS )Sendc                 C   s
   || _ dS )z'Create a Send object with target `url`.N_url)selfurl r
   P/var/www/html/venv/lib/python3.10/site-packages/sendgrid/helpers/inbound/send.py__init__   s   
zSend.__init__c                 C   s:   ddd}t | j|d}t|ddd}| }|j|dS )	zSend a test payload.

        Load a payload from payload_filepath, apply headers, and POST self.url.
        Return the response object.
        zSendGrid-Testz#multipart/form-data; boundary=xYzZY)z
User-AgentzContent-Type)hostrequest_headersrzutf-8)encoding)request_body)r   r	   r   readpost)r   payload_filepathheadersclientfdatar
   r
   r   test_payload   s   zSend.test_payloadc                 C   s   | j S )zURL to send to.r   )r   r
   r
   r   r	   #   s   zSend.urlN)__name__
__module____qualname__r   r   propertyr	   r
   r
   r
   r   r      s
    r   c                  C   s|   t  } tjdd}|jdtdd |jdtd| jdd	 | }t|j}|t	j
d
 }t|j t|j t|j d S )NzTest data and optional host.)descriptionr   zpath to the sample data)typehelpz-hostz'name of host to send the sample data toF)r   r    defaultrequired   )r   argparseArgumentParseradd_argumentstrr   
parse_argsr   r   sysargvprintstatus_coder   body)configparserargssendresponser
   r
   r   main)   s&   


r3   __main__)__doc__r$   r)   ior   r.   r   ImportErrorsendgrid.helpers.inbound.configpython_http_clientr   objectr   r3   r   r
   r
   r
   r   <module>   s    
