diff options
Diffstat (limited to 'lib/SparkPost/Transmission.php')
-rw-r--r-- | lib/SparkPost/Transmission.php | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index 613ec12..bbd1ca9 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -1,56 +1,54 @@ <?php namespace SparkPost; -use Guzzle\Http\Client; -use Guzzle\Http\Exception\ClientErrorResponseException; /** - * @desc SDK interface for managing transmissions + * SDK interface for managing transmissions */ -class Transmission extends APIResource { - +class Transmission extends APIResource +{ public $endpoint = 'transmissions'; /** - * @desc Mapping for values passed into the send method to the values needed for the Transmission API + * Mapping for values passed into the send method to the values needed for the Transmission API * @var array */ protected static $parameterMappings = [ - 'campaign'=>'campaign_id', - 'metadata'=>'metadata', - 'substitutionData'=>'substitution_data', - 'description'=>'description', - 'returnPath'=>'return_path', - 'replyTo'=>'content.reply_to', - 'subject'=>'content.subject', - 'from'=>'content.from', - 'html'=>'content.html', - 'text'=>'content.text', - 'rfc822'=>'content.email_rfc822', - 'customHeaders'=>'content.headers', - 'recipients'=>'recipients', - 'recipientList'=>'recipients.list_id', - 'template'=>'content.template_id', - 'trackOpens'=>'options.open_tracking', - 'trackClicks'=>'options.click_tracking', - 'useDraftTemplate'=>'use_draft_template' + 'campaign' => 'campaign_id', + 'metadata' => 'metadata', + 'substitutionData' => 'substitution_data', + 'description' => 'description', + 'returnPath' => 'return_path', + 'replyTo' => 'content.reply_to', + 'subject' => 'content.subject', + 'from' => 'content.from', + 'html' => 'content.html', + 'text' => 'content.text', + 'rfc822' => 'content.email_rfc822', + 'customHeaders' => 'content.headers', + 'recipients' => 'recipients', + 'recipientList' => 'recipients.list_id', + 'template' => 'content.template_id', + 'trackOpens' => 'options.open_tracking', + 'trackClicks' => 'options.click_tracking', + 'useDraftTemplate' => 'use_draft_template' ]; /** - * @desc Sets up default structure and default values for the model that is acceptable by the API + * Sets up default structure and default values for the model that is acceptable by the API * @var array */ protected static $structure = [ - 'return_path'=>'default@sparkpostmail.com', - 'content'=>[ - 'html'=>null, - 'text'=>null, - 'email_rfc822'=>null + 'return_path' => 'default@sparkpostmail.com', + 'content' => [ + 'html' => null, + 'text' => null, + 'email_rfc822' => null ], - 'use_draft_template'=>false + 'use_draft_template' => false ]; /** - * @desc Method for issuing POST request to the Transmissions API + * Method for issuing POST request to the Transmissions API * * This method assumes that all the appropriate fields have * been populated by the user through configuration. Acceptable @@ -73,34 +71,44 @@ class Transmission extends APIResource { * 'trackClicks': boolean, * 'useDraftTemplate': boolean * - * @return array API repsonse represented as key-value pairs + * @param array $transmissionConfig + * @return array API response represented as key-value pairs */ - public function send( $transmissionConfig ) { - return $this->create( $transmissionConfig ); + public function send(array $transmissionConfig) + { + return $this->create($transmissionConfig); } /** - * @desc Method for retrieving information about all transmissions + * Method for retrieving information about all transmissions * Wrapper method for a cleaner interface * + * @param null|string $campaignID + * @param null|string $templateID * @return array result Set of transmissions */ - public function all( $campaignID=null, $templateID=null ) { + public function all($campaignID = null, $templateID = null) + { $options = []; - if( $campaignID !== NULL ) $options['campaign_id'] = $campaignID; - if( $templateID !== NULL ) $options['template_id'] = $templateID; + if ($campaignID !== null) { + $options['campaign_id'] = $campaignID; + } + if ($templateID !== null) { + $options['template_id'] = $templateID; + } - return $this->get( null, $options ); + return $this->get(null, $options); } /** - * @desc Method for retrieving information about a single transmission - * Wrapper method for a cleaner interface - * + * Method for retrieving information about a single transmission + * Wrapper method for a cleaner interface + * * @param string $transmissionID Identifier of the transmission to be found * @return array result Single transmission represented in key-value pairs */ - public function find($transmissionID) { + public function find($transmissionID) + { return $this->get($transmissionID); } } |