     1: <?php
     2:
     3: class Mailchimp_Folders {
     4:     public function __construct(Mailchimp $master) {
     5:         $this->master = $master;
     6:     }
     7:
     8:     /**
     9:      * Add a new folder to file campaigns, autoresponders, or templates in
    10:      * @param string $name
    11:      * @param string $type
    12:      * @return associative_array with a single value:
    13:      *     - folder_id int the folder_id of the newly created folder.
    14:      */
    15:     public function add($name, $type) {
    16:         $_params = array("name" => $name, "type" => $type);
    17:         return $this->master->call('folders/add', $_params);
    18:     }
    19:
    20:     /**
    21:      * Delete a campaign, autoresponder, or template folder. Note that this will simply make whatever was in the folder appear unfiled, no other data is removed
    22:      * @param int $fid
    23:      * @param string $type
    24:      * @return associative_array with a single entry:
    25:      *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
    26:      */
    27:     public function del($fid, $type) {
    28:         $_params = array("fid" => $fid, "type" => $type);
    29:         return $this->master->call('folders/del', $_params);
    30:     }
    31:
    32:     /**
    33:      * List all the folders of a certain type
    34:      * @param string $type
    35:      * @return array structs for each folder, including:
    36:      *     - folder_id int Folder Id for the given folder, this can be used in the campaigns/list() function to filter on.
    37:      *     - name string Name of the given folder
    38:      *     - date_created string The date/time the folder was created
    39:      *     - type string The type of the folders being returned, just to make sure you know.
    40:      *     - cnt int number of items in the folder.
    41:      */
    42:     public function getList($type) {
    43:         $_params = array("type" => $type);
    44:         return $this->master->call('folders/list', $_params);
    45:     }
    46:
    47:     /**
    48:      * Update the name of a folder for campaigns, autoresponders, or templates
    49:      * @param int $fid
    50:      * @param string $name
    51:      * @param string $type
    52:      * @return associative_array with a single entry:
    53:      *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
    54:      */
    55:     public function update($fid, $name, $type) {
    56:         $_params = array("fid" => $fid, "name" => $name, "type" => $type);
    57:         return $this->master->call('folders/update', $_params);
    58:     }
    59:
    60: }
    61:
    62:
    63: