# File Mandrill/Metadata.php

     1: <?php
     2:
     3: class Mandrill_Metadata {
     4:     public function __construct(Mandrill $master) {
     5:         $this->master = $master;
     6:     }
     7:
     8:     /**
     9:      * Get the list of custom metadata fields indexed for the account.
    10:      * @return array the custom metadata fields for the account
    11:      *     - return[] struct the individual custom metadata field info
    12:      *         - name string the unique identifier of the metadata field to update
    13:      *         - state string the current state of the metadata field, one of "active", "delete", or "index"
    14:      *         - view_template string Mustache template to control how the metadata is rendered in your activity log
    15:      */
    16:     public function getList() {
    17:         $_params = array();
    18:         return $this->master->call('metadata/list', $_params);
    19:     }
    20:
    21:     /**
    22:      * Add a new custom metadata field to be indexed for the account.
    23:      * @param string $name a unique identifier for the metadata field
    24:      * @param string $view_template optional Mustache template to control how the metadata is rendered in your activity log
    25:      * @return struct the information saved about the new metadata field
    26:      *     - name string the unique identifier of the metadata field to update
    27:      *     - state string the current state of the metadata field, one of "active", "delete", or "index"
    28:      *     - view_template string Mustache template to control how the metadata is rendered in your activity log
    29:      */
    30:     public function add($name, $view_template=null) {
    31:         $_params = array("name" => $name, "view_template" => $view_template);
    32:         return $this->master->call('metadata/add', $_params);
    33:     }
    34:
    35:     /**
    36:      * Update an existing custom metadata field.
    37:      * @param string $name the unique identifier of the metadata field to update
    38:      * @param string $view_template optional Mustache template to control how the metadata is rendered in your activity log
    39:      * @return struct the information for the updated metadata field
    40:      *     - name string the unique identifier of the metadata field to update
    41:      *     - state string the current state of the metadata field, one of "active", "delete", or "index"
    42:      *     - view_template string Mustache template to control how the metadata is rendered in your activity log
    43:      */
    44:     public function update($name, $view_template) {
    45:         $_params = array("name" => $name, "view_template" => $view_template);
    46:         return $this->master->call('metadata/update', $_params);
    47:     }
    48:
    49:     /**
    50:      * Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.
    51:      * @param string $name the unique identifier of the metadata field to update
    52:      * @return struct the information for the deleted metadata field
    53:      *     - name string the unique identifier of the metadata field to update
    54:      *     - state string the current state of the metadata field, one of "active", "delete", or "index"
    55:      *     - view_template string Mustache template to control how the metadata is rendered in your activity log
    56:      */
    57:     public function delete($name) {
    58:         $_params = array("name" => $name);
    59:         return $this->master->call('metadata/delete', $_params);
    60:     }
    61:
    62: }
    63:
    64:
    65: