1 <?php
 2 namespace MailChimp\Campaigns;
 3 
 4 use MailChimp\MailChimp as MailChimp;
 5 
 6 class Content extends MailChimp
 7 {
 8 
 9 
10     /**
11      * Get the the HTML and plain-text content for a campaign.
12      *
13      * array["fields"]              array       list of strings of response fields to return
14      * array["exclude_fields"]      array       list of strings of response fields to exclude (not to be used with "fields")
15      *
16      * @param string $campaign_id for the campaign instance
17      * @param array $query (See Above) OPTIONAL associative array of query parameters.
18      * @return object
19      */
20     public function getCampaignContent($campaign_id, array $query = [])
21     {
22         return self::execute("GET", "campaigns/{$campaign_id}/content", $query);
23     }
24 
25     /**
26      * Set the content for a campaign.
27      *
28      * array $optional_settings     array
29      *      ["plain_text"]          string   The plain-text portion of the campaign.
30      *      ["html"]                string   The raw HTML for the campaign.
31      *      ["url"]                 string   When importing a campaign, the URL where the HTML lives.
32      *      ["template"]            array   Use this template to generate the HTML content of the campaign
33      *          ["id"]              int     REQUIRED WHEN USING TEMPLATE The id of the template to use.
34      *          ["sections"]        array   Content for the sections of the template. Each key should be the unique mc:edit area name from the template.
35      *      ["archive"]             array   Available when uploading an archive to create campaign content.
36      *          ["archive_content"] string  REQUIRED WHEN USING ARCHIVE base64-encoded representation of the archive file.
37      *          ["archive_type"]    string  The type of encoded file. Defaults to zip.
38      *                                      Possible Values: zip, tar.gz, tar.bz2,tar, tgz, tbz
39      *
40      * @param string $campaign_id for the campaign instance
41      * @param array $optional_settings (See Above for available fields)
42      * @return object
43      */
44     public function setCampaignContent($campaign_id, array $optional_settings = [])
45     {
46         $optional_fields = ["plain_text", "html", "url", "template", "archive", "variate_contents" ];
47 
48         // If the optional fields are passed, process them against the list of optional fields.
49         if (isset($optional_settings)) {
50             $data = array_merge($data, self::optionalFields($optional_fields, $optional_settings));
51         }
52         return self::execute("PUT", "campaigns/{$campaign_id}/content", $data);
53     }
54 
55 
56 
57 }
58