o
    ÛtBh   ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   s>   e Zd ZdZ					ddd„Zdd„ Zddd„Zd	d
„ ZdS )ÚApiResponsea  
    Api Response

    Wrapper around all responses from the API.

    Examples:
        literal blocks::

            response = Orders().get_orders(CreatedAfter='TEST_CASE_200', MarketplaceIds=["ATVPDKIKX0DER"])

            print(response.payload) # original response data
            # Access one of `payload`s properties using `__getattr__`
            print(response.Orders) # Array of orders
            # Access one of `payload`s properties using `__call__`
            print(response('Orders')) # Array of orders
            # Shorthand for response.payload
            print(response()) # original response data

    Args:
        payload: dict or list | original response from Amazon
        errors: any | contains possible error messages
        pagination: any | information about an endpoints pagination
        headers: any | headers returned by the API
        rate_limit: number | The `x-amzn-RateLimit-Limit` header, if available
        next_token: str | The next token used to retrieve the next page, if any
        kwargs: any

    Nc                 K   s€   |p|| _ || _|| _|| _| d¡| _z|p$| j  dd ¡p$| j dd ¡| _W n ty3   d | _Y nw || j kr>|| _d S d S )Nzx-amzn-RateLimit-LimitÚ	NextTokenÚ	nextToken)	ÚpayloadÚerrorsÚ
paginationÚheadersÚgetÚ
rate_limitÚ
next_tokenÚAttributeErrorÚkwargs)Úselfr   r   r   r   r   r   © r   ún/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sp_api/base/ApiResponse.pyÚ__init__"   s"   
	ÿý
ÿ

ÿzApiResponse.__init__c                 C   s   t  t| ƒ¡S ©N)ÚpprintÚpformatÚvars)r   r   r   r   Ú__str__<   s   zApiResponse.__str__c                 K   s   |s| j S | j  |¡S r   ©r   r	   )r   Úitemr   r   r   r   Ú__call__?   s   zApiResponse.__call__c                 C   s   | j  |¡S r   r   )r   r   r   r   r   Ú__getattr__D   s   zApiResponse.__getattr__)NNNNNr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    
ú
r   )r   r   r   r   r   r   Ú<module>   s    