o
    ˷em                     @   s0   d Z ddlmZ ddlmZ G dd deZdS )a  
The E-commerce Store Product Variants API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/
Schema: https://api.mailchimp.com/schema/3.0/Ecommerce/Stores/Products/Variants/Instance.json
    )unicode_literals)BaseApic                       sR   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	dd Z
  ZS )StoreProductVariantsz
    A Product Variant represents a specific item for purchase, and is
    contained within a parent Product. At least one Product Variant is
    required for each Product.
    c                    s2   t t| j|i | d| _d| _d| _d| _dS )z)
        Initialize the endpoint
        zecommerce/storesN)superr   __init__endpointstore_id
product_id
variant_id)selfargskwargs	__class__ _/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/storeproductvariants.pyr      s
   
zStoreProductVariants.__init__c                 C   sh   || _ || _d|vrtdd|vrtd| jj| |d|d|d}|dur/|d | _|S d| _|S )	a  
        Add a new variant to the product.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "title": string*
        }
        id#The product variant must have an idtitle%The product variant must have a titleproductsvariantsurldataN)r   r	   KeyError
_mc_client_post_build_pathr
   )r   r   r	   r   responser   r   r   create   s   
zStoreProductVariants.createFc              	   K   sX   || _ || _d| _|r| jdd| |d|di|S | jjdd| |d|di|S )u-  
        Get information about a product’s variants.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_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   all;   s    
zStoreProductVariants.allc              
   K   s6   || _ || _|| _| jjdd| |d|d|i|S )a  
        Get information about a specific product variant.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param variant_id: The id for the product variant.
        :type variant_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   getW   s   
zStoreProductVariants.getc                 C   s0   || _ || _|| _| jj| |d|d||dS )a  
        Update a product variant.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param variant_id: The id for the product variant.
        :type variant_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        r   r   r   )r   r	   r
   r   _patchr   r   r   r	   r
   r   r   r   r   updaten   s   zStoreProductVariants.updatec                 C   sP   || _ || _|| _d|vrtdd|vrtd| jj| |d|d||dS )a  
        Add or update a product variant.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param variant_id: The id for the product variant.
        :type variant_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "id": string*,
            "title": string*
        }
        r   r   r   r   r   r   r   )r   r	   r
   r   r   _putr   r(   r   r   r   create_or_update   s   z%StoreProductVariants.create_or_updatec                 C   s.   || _ || _|| _| jj| |d|d|dS )aH  
        Delete a product variant.

        :param store_id: The store id.
        :type store_id: :py:class:`str`
        :param product_id: The id for the product of a store.
        :type product_id: :py:class:`str`
        :param variant_id: The id for the product variant.
        :type variant_id: :py:class:`str`
        r   r   )r   )r   r	   r
   r   _deleter   )r   r   r	   r
   r   r   r   delete   s   zStoreProductVariants.delete)F)__name__
__module____qualname____doc__r   r    r%   r&   r)   r+   r-   __classcell__r   r   r   r   r      s    
r   N)r1   
__future__r   mailchimp3.baseapir   r   r   r   r   r   <module>   s   