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 CodesAPI 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 )StorePromoCodesz
        Promo Promo codes can be created for a given promo rule. All the promo codes under a promo rule share the
        generic information defined for that rule like the amount, type, expiration date 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/storepromocodes.pyr      s   
zStorePromoCodes.__init__c                 C   sb   || _ d|vrtdd|vrtdd|vrtd| jj| |d|d|d	}|d
ur/|S d
S )a  
        Add a new promo code 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*,
            "code": string*,
            "redemption_url": string*,
            "usage_count": string,
            "enabled": boolean,
            "created_at_foreign": string,
            "updated_at_foreign": string,
        }
        idzThe promo code must have an idcodez This promo code must have a coderedemption_urlz*This promo code must have a redemption urlpromo-rulespromo-codesurldataN)r   KeyError
_mc_client_post_build_path)r	   r   promo_rule_idr   responser   r   r   create   s   zStorePromoCodes.createFc              	   K   sP   || _ || _|r| jdd| |d|di|S | jjdd| |d|i|S )u  
        Get information about a store’s promo codes.

        :param store_id: The store's id
        :type store_id: `str`
        :param promo_rule_id: The store promo rule 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   r   z
promo-ruleNr   )r   r   _iterater   r   _get)r	   r   r   get_allqueryparamsr   r   r   all7   s
     zStorePromoCodes.allc              
   K   s6   || _ || _|| _| jjdd| |d|d|i|S )a  
                Get information about a specific promo code.

                :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   r   Nr   )r   r   promo_code_idr   r    r   )r	   r   r   r$   r"   r   r   r   getN   s   $zStorePromoCodes.getc                 C   s0   || _ || _|| _| jj| |d|d||dS )a  
        Update a promo code

        :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 promo_code_id: The id for the promo code 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   r$   r   _patchr   )r	   r   r   r$   r   r   r   r   update`   s   zStorePromoCodes.updatec                 C   s(   || _ || _| jj| |d|d|dS )a-  
        Delete a promo code
        :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 promo_code_id: The id for the promo code of a store.
        :type :py:class:`str`
        r   r   )r   )r   r   r   _deleter   )r	   r   r   r$   r   r   r   delete   s   
zStorePromoCodes.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   