o
    >_Wc	                     @   sB   d dl Z d dlmZ e jrd dlmZ dd Zdd Zdd	 ZdS )
    N)PersistenceException)RequestEnvelopec                 C   *   z	| j jjj}|W S  ty   tdw )a`  Retrieve user id from request envelope, to use as partition key.

    :param request_envelope: Request Envelope passed during skill
        invocation
    :type request_envelope: ask_sdk_model.RequestEnvelope
    :return: User Id retrieved from request envelope
    :rtype: str
    :raises: :py:class:`ask_sdk_core.exceptions.PersistenceException`
    zFCouldn't retrieve user id from request envelope, for partition key use)contextsystemuseruser_idAttributeErrorr   )request_enveloper    r   CD:\Flask\env\Lib\site-packages\ask_sdk_dynamodb/partition_keygen.pyuser_id_partition_keygen      r   c                 C   r   )ad  Retrieve device id from request envelope, to use as partition key.

    :param request_envelope: Request Envelope passed during skill
        invocation
    :type request_envelope: ask_sdk_model.RequestEnvelope
    :return: Device Id retrieved from request envelope
    :rtype: str
    :raises: :py:class:`ask_sdk_core.exceptions.PersistenceException`
    zHCouldn't retrieve device id from request envelope, for partition key use)r   r   Zdevice	device_idr	   r   )r
   r   r   r   r   device_id_partition_keygen-   r   r   c                 C   sL   z	| j jjj}W |S  ty%   z	t| d}W Y |S  ty$   tdw w )a_  Retrieve person id from request envelope, to use as object key.

    This method retrieves the `person id` specific to a voice profile from
    the request envelope if it exists, to be used as an object key. If it
    doesn't exist, then the `user id` is returned instead.

    :param request_envelope: Request Envelope passed during skill
        invocation
    :type request_envelope: ask_sdk_model.RequestEnvelope
    :return: person Id retrieved from request envelope if exists, else
        fall back on User Id
    :rtype: str
    :raises: :py:class:`ask_sdk_core.exceptions.PersistenceException`
    )r
   zSCouldn't retrieve person id or user id from request envelope, for partition key use)r   r   Zperson	person_idr	   r   r   )r
   r   r   r   r   person_id_partition_keygen@   s   	
r   )	typingZask_sdk_core.exceptionsr   TYPE_CHECKINGZask_sdk_modelr   r   r   r   r   r   r   r   <module>   s   