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 Stores Promo Rules API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/promo-rules
    )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 )StorePromoRulesz
    Promo Rules help you create promo codes for your campaigns. Promo Rules define generic information about promo
    codes like expiration time, start time, amount of discount being offered etc
    c                    s&   t t| j|i | d| _d| _dS )zU
        Initialize the Endpoint
        :param args:
        :param kwargs:
        zecommerce/storesN)superr   __init__endpointstore_id)selfargskwargs	__class__ Z/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/storepromorules.pyr      s   
zStorePromoRules.__init__c                 C   sn   || _ 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ur5|S dS )aZ  
        Add new promo rule to 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'
        data = {
            "id": string*,
            "title": string,
            "description": string*,
            "starts_at": string,
            "ends_at": string,
            "amount": number*,
            "type": string*,
            "target": string*,
            "enabled": boolean,
            "created_at_foreign": string,
            "updated_at_foreign": string,
        }
        idzThe promo rule must have an iddescriptionz'This promo rule must have a descriptionamountz#This promo rule must have an amounttargetzLThis promo rule must apply to a target (example per_item, total, or shippingpromo-rulesurldataN)r   KeyError
_mc_client_post_build_path)r	   r   r   responser   r   r   create   s   zStorePromoRules.createFc                 K   sD   || _ |r| jdd| |di|S | jjdd| |di|S )u  
        Get information about a store’s promo rules.

        :param store_id: The store's id
        :type store_id: `str`
        :param get_all:
        :type get_all: :py:class:`bool`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        queryparams['count'] = integer
        queryparams['offset'] = integer
        r   r   Nr   )r   _iterater   r   _get)r	   r   get_allqueryparamsr   r   r   all=   s   zStorePromoRules.allc                 K   s,   || _ || _| jjdd| |d|i|S )a  
                Get information about a specific promo rule.

                :param store_id: The store's id
                :type store_id: `string`
                :param queryparams: The query string parameters
                queryparams['fields'] = []
                queryparams['exclude_fields'] = []
                queryparams['count'] = integer
                queryparams['offset'] = integer
                r   r   Nr   )r   promo_rule_idr   r   r   )r	   r   r#   r!   r   r   r   getQ   s    zStorePromoRules.getc                 C   s&   || _ || _| jj| |d||dS )a  
        Update a promo rule

        :param store_id: The store id
        :type :py:class:`str`
        :param promo_rule_id: The id for the promo rule of a store.
        :type :py:class:`str`
        :param data:
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string,
            "title": string,
            "description": string,
            "starts_at": string,
            "ends_at": string,
            "amount": number,
            "type": string,
            "target": string,
            "enabled": boolean,
            "created_at_foreign": string,
            "updated_at_foreign": string,
        }
        r   r   )r   r#   r   _patchr   )r	   r   r#   r   r   r   r   updateb   s   zStorePromoRules.updatec                 C   s$   || _ || _| jj| |d|dS )z
        Delete a promo rule
        :param store_id: The store id
        :type :py:class:`str`
        :param promo_rule_id: The id for the promo rule of a store.
        :type :py:class:`str`
        r   )r   )r   r#   r   _deleter   )r	   r   r#   r   r   r   delete   s   zStorePromoRules.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   