o
    ˷e                     @   sh   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ G d	d
 d
eZdS )z
The E-commerce Stores API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/
Schema: https://api.mailchimp.com/schema/3.0/Ecommerce/Stores/Instance.json
    )unicode_literalsN)BaseApi)
StoreCarts)StoreCustomers)StoreOrders)StoreProductsc                       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 )Storesz
    Connect your E-commerce Store to MailChimp to take advantage of powerful
    reporting and personalization features and to learn more about your
    customers.
    c                    sN   t t| j|i | d| _d| _t| | _t| | _t	| | _
t| | _dS )z)
        Initialize the endpoint
        zecommerce/storesN)superr   __init__endpointstore_idr   cartsr   	customersr   ordersr   products)selfargskwargs	__class__ Q/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/stores.pyr
      s   


zStores.__init__c                 C   s   d|vrt dd|vrt dd|vrt dd|vr t dtd	|d s,td
| jj|  |d}|durA|d | _|S d| _|S )a#  
        Add a new store to your MailChimp account.

        Error checking on the currency code verifies that it is in the correct
        three-letter, all-caps format as specified by ISO 4217 but does not
        check that it is a valid code as the list of valid codes changes over
        time.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "list_id": string*,
            "name": string*,
            "currency_code": string*
        }
        idzThe store must have an idlist_idzThe store must have a list_idnamezThe store must have a namecurrency_codez#The store must have a currency_codez
^[A-Z]{3}$zAThe currency_code must be a valid 3-letter ISO 4217 currency codeurldataN)KeyErrorrematch
ValueError
_mc_client_post_build_pathr   )r   r   responser   r   r   create%   s    
zStores.createFc                 K   s<   d| _ |r| jdd|  i|S | jjdd|  i|S )ay  
        Get information about all stores in the account.

        :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   _iterater%   r#   _get)r   get_allqueryparamsr   r   r   allI   s   z
Stores.allc                 K   s"   || _ | jjdd| |i|S )a  
        Get information about a specific store.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        r   Nr   )r   r#   r)   r%   )r   r   r+   r   r   r   get\   s   
z
Stores.getc                 C   s   || _ | jj| ||dS )z
        Update a store.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        r   )r   r#   _patchr%   )r   r   r   r   r   r   updatej   s   	zStores.updatec                 C   s   || _ | jj| |dS )z
        Delete a store. Deleting a store will also delete any associated
        subresources, including Customers, Orders, Products, and Carts.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        )r   )r   r#   _deleter%   )r   r   r   r   r   deletew   s   zStores.delete)F)__name__
__module____qualname____doc__r
   r'   r,   r-   r/   r1   __classcell__r   r   r   r   r      s    
$r   )r5   
__future__r   r    mailchimp3.baseapir   mailchimp3.entities.storecartsr   "mailchimp3.entities.storecustomersr   mailchimp3.entities.storeordersr   !mailchimp3.entities.storeproductsr   r   r   r   r   r   <module>   s   