o
    ˷en                     @   sH   d 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 Campaigns API actions endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/
Schema: https://api.mailchimp.com/schema/3.0/CampaignFolders/Instance.json
    )unicode_literals)	timedelta)BaseApi)check_emailc                       sh   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Z  ZS )CampaignActionsz
    Campaigns are how you send emails to your MailChimp list. Use the
    Campaigns API calls to manage campaigns in your MailChimp account.
    c                    s&   t t| j|i | d| _d| _dS )z)
        Initialize the endpoint
        	campaignsN)superr   __init__endpointcampaign_id)selfargskwargs	__class__ Z/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/campaignactions.pyr	      s   
zCampaignActions.__init__c                 C      || _ | jj| |ddS )a  
        Cancel a Regular or Plain-Text Campaign after you send, before all of
        your recipients receive it. This feature is included with MailChimp
        Pro.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/cancel-sendurlr   
_mc_client_post_build_pathr   r   r   r   r   cancel      	zCampaignActions.cancelc                 C   r   )z
        Pause an RSS-Driven campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/pauser   r   r   r   r   r   pause,      zCampaignActions.pausec                 C   r   )z
        Replicate a campaign in saved or send status.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/replicater   r   r   r   r   r   	replicate7   r   zCampaignActions.replicatec                 C   r   )z
        Resume an RSS-Driven campaign.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/resumer   r   r   r   r   r   resumeB   r   zCampaignActions.resumec                 C   s   |d st d|d jdu rt d|d jdtdkr#t d|d jdvr.t d|d d|d< || _| jj| 	|d	|d
S )u  
        Schedule a campaign for delivery. If you’re using Multivariate
        Campaigns to test send times or sending RSS Campaigns, use the send
        action instead.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "schedule_time": datetime* (A UTC timezone datetime that ends on the quarter hour [:00, :15, :30, or :45])
        }
        schedule_timezYou must supply a schedule_timeNz The schedule_time must be in UTCr   )r         -   z?The schedule_time must end on the quarter hour (00, 15, 30, 45)z%Y-%m-%dT%H:%M:00+00:00zactions/scheduler   data)

ValueErrortzinfo	utcoffsetr   minutestrftimer   r   r   r   )r   r   r&   r   r   r   scheduleM   s   zCampaignActions.schedulec                 C   r   )a  
        Send a MailChimp campaign. For RSS Campaigns, the campaign will send
        according to its schedule. All other campaigns will send immediately.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/sendr   r   r   r   r   r   sendj   s   zCampaignActions.sendc                 C   r   )a  
        Creates a Resend to Non-Openers version of this campaign. We will also
        check if this campaign meets the criteria for Resend to Non-Openers
        campaigns.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/create-resendr   r   r   r   r   r   resendv   r   zCampaignActions.resendc                 C   sH   |d D ]}t | q|d dvrtd|| _| jj| |d|dS )ah  
        Send a test email.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "test_emails": array*,
            "send_type": string* (Must be one of "html" or "plaintext")
        }
        test_emails	send_type)html	plaintextz2The send_type must be either "html" or "plaintext"zactions/testr%   )r   r'   r   r   r   r   )r   r   r&   emailr   r   r   test   s   
zCampaignActions.testc                 C   r   )u   
        Unschedule a scheduled campaign that hasn’t started sending.

        :param campaign_id: The unique id for the campaign.
        :type campaign_id: :py:class:`str`
        zactions/unscheduler   r   r   r   r   r   
unschedule   r   zCampaignActions.unschedule)__name__
__module____qualname____doc__r	   r   r   r   r    r,   r-   r.   r4   r5   __classcell__r   r   r   r   r      s    
r   N)
r9   
__future__r   datetimer   mailchimp3.baseapir   mailchimp3.helpersr   r   r   r   r   r   <module>   s   