U
    Fc                     @   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k
rP   ddlmZ Y nX ddl	m
Z
 G dd deZdd	 Zed
kre  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
   A/tmp/pip-unpacked-wheel-7j3043uk/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)hostZrequest_headersrzutf-8)encoding)request_body)r   r	   r   readpost)r   Z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(     


r1   __main__)__doc__r"   r'   ior   r,   r   ImportErrorZsendgrid.helpers.inbound.configZpython_http_clientr   objectr   r1   r   r
   r
   r
   r   <module>   s   