U
    3ìdÛ  ã                   @   s@   d dl Z d dlmZ d dlmZ d dlmZ G dd„ deƒZdS )é    N)Ú	MHMessage)ÚSQSDecodeError)Újsonc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚJSONMessagezX
    Acts like a dictionary but encodes it's data as a Base64 encoded JSON payload.
    c                 C   s@   z$t  | d¡¡ d¡}t |¡}W n   td| ƒ‚Y nX |S )Núutf-8zUnable to decode message)Úbase64Ú	b64decodeÚencodeÚdecoder   Úloadsr   ©ÚselfÚvalue© r   ú8/tmp/pip-unpacked-wheel-d7dsrkjd/boto/sqs/jsonmessage.pyr
   !   s    zJSONMessage.decodec                 C   s    t  |¡}t | d¡¡ d¡S )Nr   )r   Údumpsr   Ú	b64encoder	   r
   r   r   r   r   r	   )   s    
zJSONMessage.encodeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r	   r   r   r   r   r      s   r   )r   Zboto.sqs.messager   Zboto.exceptionr   Zboto.compatr   r   r   r   r   r   Ú<module>   s   