U
    Fc                     @   s   d dl Z G dd deZdS )    Nc                   @   s0   e Zd Zdd Zedd Zdd Zdd Zd	S )
BaseInterfacec                 C   sL   ddl m} || _|| _|| _|| _d| j| _tj	| j| j
dd| _dS )a  
        Construct the Twilio SendGrid v3 API object.
        Note that the underlying client is being set up during initialization,
        therefore changing attributes in runtime will not affect HTTP client
        behaviour.

        :param auth: the authorization header
        :type auth: string
        :param impersonate_subuser: the subuser to impersonate. Will be passed
                                    by "On-Behalf-Of" header by underlying
                                    client. See
                                    https://sendgrid.com/docs/User_Guide/Settings/subusers.html
                                    for more details
        :type impersonate_subuser: string
        :param host: base URL for API calls
        :type host: string
           )__version__zsendgrid/{};python   )hostrequest_headersversionN) r   authr   impersonate_subuserr   format	useragentpython_http_clientZClient_default_headersclient)selfr
   r   r   r    r   ;/tmp/pip-unpacked-wheel-7j3043uk/sendgrid/base_interface.py__init__   s    zBaseInterface.__init__c                 C   s$   | j | jdd}| jr | j|d< |S )z8Set the default header for a Twilio SendGrid v3 API callzapplication/json)Authorizationz
User-AgentAcceptzOn-Behalf-Of)r
   r   r   )r   headersr   r   r   r   #   s    
zBaseInterface._default_headersc                 C   s   | j | j_d S )N)r   r   r   )r   r   r   r   reset_request_headers0   s    z#BaseInterface.reset_request_headersc                 C   s$   t |ts| }| jjjj|dS )zMake a Twilio SendGrid v3 API request with the request body generated by
           the Mail object

        :param message: The Twilio SendGrid v3 API request body generated by the Mail
                        object
        :type message: Mail
        )request_body)
isinstancedictgetr   mailsendpost)r   messager   r   r   r   3   s    
zBaseInterface.sendN)__name__
__module____qualname__r   propertyr   r   r   r   r   r   r   r      s
   
r   )r   objectr   r   r   r   r   <module>   s   