ó
ş9^c           @   sŻ   d  Z  d d l Z d d l Z d d l m Z y d d l m Z Wn! e k
 re d d l m Z n Xd d l	 m
 Z
 d e f d     YZ d   Z e d	 k rĞ e   n  d S(
   so   A module for sending test SendGrid Inbound Parse messages.
Usage: ./send.py [path to file containing test data]i˙˙˙˙N(   t   open(   t   Config(   t   Clientt   Sendc           B   s)   e  Z d    Z d   Z e d    Z RS(   c         C   s   | |  _  d S(   s'   Create a Send object with target `url`.N(   t   _url(   t   selft   url(    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyt   __init__   s    c         C   s]   i d d 6d d 6} t  d |  j d |  } t | d d d	 } | j   } | j d
 |  S(   s   Send a test payload.

        Load a payload from payload_filepath, apply headers, and POST self.url.
        Return the response object.
        s   SendGrid-Tests
   User-Agents#   multipart/form-data; boundary=xYzZYs   Content-Typet   hostt   request_headerst   rt   encodings   utf-8t   request_body(   R   R   R    t   readt   post(   R   t   payload_filepatht   headerst   clientt   ft   data(    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyt   test_payload   s    
c         C   s   |  j  S(   s   URL to send to.(   R   (   R   (    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyR   #   s    (   t   __name__t
   __module__R   R   t   propertyR   (    (    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyR      s   		c       
   C   sİ   t    }  t j d d  } | j d d t d d | j d d t d d d	 |  j d
 t | j   } t | j  } | j	 t
 j d  } | j GH| j GH| j GHd  S(   Nt   descriptions   Test data and optional host.R   t   typet   helps   path to the sample datas   -hosts'   name of host to send the sample data tot   defaultt   requiredi   (   R   t   argparset   ArgumentParsert   add_argumentt   strR   t   Falset
   parse_argsR   R   t   syst   argvt   status_codeR   t   body(   t   configt   parsert   argst   sendt   response(    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyt   main)   s     			t   __main__(   t   __doc__R   R#   t   ioR    R'   R   t   ImportErrort   sendgrid.helpers.inbound.configt   python_http_clientR   t   objectR   R,   R   (    (    (    s?   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/inbound/send.pyt   <module>   s   	