File Mandrill/Exports.php

      1: <?php
      2:
      3: class Mandrill_Exports {
      4:     public function __construct(Mandrill $master) {
      5:         $this->master = $master;
      6:     }
      7:
      8:     /**
      9:      * Returns information about an export job. If the export job's state is 'complete',
     10: the returned data will include a URL you can use to fetch the results. Every export
     11: job produces a zip archive, but the format of the archive is distinct for each job
     12: type. The api calls that initiate exports include more details about the output format
     13: for that job type.
     14:      * @param string $id an export job identifier
     15:      * @return struct the information about the export
     16:      *     - id string the unique identifier for this Export. Use this identifier when checking the export job's status
     17:      *     - created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     18:      *     - type string the type of the export job - activity, reject, or whitelist
     19:      *     - finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format
     20:      *     - state string the export job's state - waiting, working, complete, error, or expired.
     21:      *     - result_url string the url for the export job's results, if the job is completed.
     22:      */
     23:     public function info($id) {
     24:         $_params = array("id" => $id);
     25:         return $this->master->call('exports/info', $_params);
     26:     }
     27:
     28:     /**
     29:      * Returns a list of your exports.
     30:      * @return array the account's exports
     31:      *     - return[] struct the individual export info
     32:      *         - id string the unique identifier for this Export. Use this identifier when checking the export job's status
     33:      *         - created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     34:      *         - type string the type of the export job - activity, reject, or whitelist
     35:      *         - finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format
     36:      *         - state string the export job's state - waiting, working, complete, error, or expired.
     37:      *         - result_url string the url for the export job's results, if the job is completed.
     38:      */
     39:     public function getList() {
     40:         $_params = array();
     41:         return $this->master->call('exports/list', $_params);
     42:     }
     43:
     44:     /**
     45:      * Begins an export of your rejection blacklist. The blacklist will be exported to a zip archive
     46: containing a single file named rejects.csv that includes the following fields: email,
     47: reason, detail, created_at, expires_at, last_event_at, expires_at.
     48:      * @param string $notify_email an optional email address to notify when the export job has finished.
     49:      * @return struct information about the rejects export job that was started
     50:      *     - id string the unique identifier for this Export. Use this identifier when checking the export job's status
     51:      *     - created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     52:      *     - type string the type of the export job
     53:      *     - finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
     54:      *     - state string the export job's state
     55:      *     - result_url string the url for the export job's results, if the job is complete
     56:      */
     57:     public function rejects($notify_email=null) {
     58:         $_params = array("notify_email" => $notify_email);
     59:         return $this->master->call('exports/rejects', $_params);
     60:     }
     61:
     62:     /**
     63:      * Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive
     64: containing a single file named whitelist.csv that includes the following fields:
     65: email, detail, created_at.
     66:      * @param string $notify_email an optional email address to notify when the export job has finished.
     67:      * @return struct information about the whitelist export job that was started
     68:      *     - id string the unique identifier for this Export. Use this identifier when checking the export job's status
     69:      *     - created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
     70:      *     - type string the type of the export job
     71:      *     - finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
     72:      *     - state string the export job's state
     73:      *     - result_url string the url for the export job's results, if the job is complete
     74:      */
     75:     public function whitelist($notify_email=null) {
     76:         $_params = array("notify_email" => $notify_email);
     77:         return $this->master->call('exports/whitelist', $_params);
     78:     }
     79:
     80:     /**
     81:      * Begins an export of your activity history. The activity will be exported to a zip archive
     82: containing a single file named activity.csv in the same format as you would be able to export
     83: from your account's activity view. It includes the following fields: Date, Email Address,
     84: Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom
     85: metadata fields, they will be included in the exported data.
     86:      * @param string $notify_email an optional email address to notify when the export job has finished
     87:      * @param string $date_from start date as a UTC string in YYYY-MM-DD HH:MM:SS format
     88:      * @param string $date_to end date as a UTC string in YYYY-MM-DD HH:MM:SS format
     89:      * @param array $tags an array of tag names to narrow the export to; will match messages that contain ANY of the tags
     90:      *     - tags[] string a tag name
     91:      * @param array $senders an array of senders to narrow the export to
     92:      *     - senders[] string a sender address
     93:      * @param array $states an array of states to narrow the export to; messages with ANY of the states will be included
     94:      *     - states[] string a message state
     95:      * @param array $api_keys an array of api keys to narrow the export to; messsagse sent with ANY of the keys will be included
     96:      *     - api_keys[] string an API key associated with your account
     97:      * @return struct information about the activity export job that was started
     98:      *     - id string the unique identifier for this Export. Use this identifier when checking the export job's status
     99:      *     - created_at string the date and time that the export job was created as a UTC string in YYYY-MM-DD HH:MM:SS format
    100:      *     - type string the type of the export job
    101:      *     - finished_at string the date and time that the export job was finished as a UTC string in YYYY-MM-DD HH:MM:SS format, or null for jobs that have not run
    102:      *     - state string the export job's state
    103:      *     - result_url string the url for the export job's results, if the job is complete
    104:      */
    105:     public function activity($notify_email=null, $date_from=null, $date_to=null, $tags=null, $senders=null, $states=null, $api_keys=null) {
    106:         $_params = array("notify_email" => $notify_email, "date_from" => $date_from, "date_to" => $date_to, "tags" => $tags, "senders" => $senders, "states" => $states, "api_keys" => $api_keys);
    107:         return $this->master->call('exports/activity', $_params);
    108:     }
    109:
    110: }
    111:
    112:
    113: