o
    ˷e                     @   s0   d Z ddlmZ ddlmZ G dd deZdS )z
The E-commerce Store Orders endpoint API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/
Schema: https://api.mailchimp.com/schema/3.0/Ecommerce/Stores/Customers/Instance.json
    )unicode_literals)BaseApic                       sJ   e Zd ZdZ fddZdd ZdddZd	d
 Zdd Zdd Z	  Z
S )StoreOrderLinesz
    Each Order contains one or more Order Lines, which represent a specific
    Product Variant that a Customer purchases.
    c                    s2   t t| j|i | d| _d| _d| _d| _dS )z)
        Initialize the endpoint
        zecommerce/storesN)superr   __init__endpointstore_idorder_idline_id)selfargskwargs	__class__ Z/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/storeorderlines.pyr      s
   
zStoreOrderLines.__init__c                 C   s   || _ || _d|vrtdd|vrtdd|vrtdd|vr&tdd	|vr.td
| jj| |d|dd}|durF|d | _|S d| _|S )a  
        Add a new line item to an existing order.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "product_id": string*,
            "product_variant_id": string*,
            "quantity": integer*,
            "price": number*
        }
        idzThe order line must have an id
product_idz%The order line must have a product_idproduct_variant_idz-The order line must have a product_variant_idquantityz#The order line must have a quantitypricez The order line must have a priceorderslinesurlN)r   r	   KeyError
_mc_client_post_build_pathr
   )r   r   r	   dataresponser   r   r   create   s$   
zStoreOrderLines.createFc              	   K   sX   || _ || _d| _|r| jdd| |d|di|S | jjdd| |d|di|S )u(  
        Get information about an order’s line items.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param get_all: Should the query get all results
        :type get_all: :py:class:`bool`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        queryparams['count'] = integer
        queryparams['offset'] = integer
        Nr   r   r   r   )r   r	   r
   _iterater   r   _get)r   r   r	   get_allqueryparamsr   r   r   allC   s    "zStoreOrderLines.allc              
   K   s6   || _ || _|| _| jjdd| |d|d|i|S )a  
        Get information about a specific order line item.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param line_id: The id for the line item of a cart.
        :type line_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        r   r   r   Nr   )r   r	   r
   r   r#   r   )r   r   r	   r
   r%   r   r   r   get\   s   $zStoreOrderLines.getc                 C   s0   || _ || _|| _| jj| |d|d||dS )a  
        Update a specific order line item.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param line_id: The id for the line item of a cart.
        :type line_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        r   r   )r   r   )r   r	   r
   r   _patchr   )r   r   r	   r
   r   r   r   r   updatep   s   zStoreOrderLines.updatec                 C   s.   || _ || _|| _| jj| |d|d|dS )aI  
        Delete a specific order line item.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param order_id: The id for the order in a store.
        :type order_id: :py:class:`str`
        :param line_id: The id for the line item of a cart.
        :type line_id: :py:class:`str`
        r   r   r   )r   r	   r
   r   _deleter   )r   r   r	   r
   r   r   r   delete   s   zStoreOrderLines.delete)F)__name__
__module____qualname____doc__r   r!   r&   r'   r)   r+   __classcell__r   r   r   r   r      s    
&r   N)r/   
__future__r   mailchimp3.baseapir   r   r   r   r   r   <module>   s   