diff options
author | Vincent Song <vincent.wsong@gmail.com> | 2016-06-10 15:16:45 -0400 |
---|---|---|
committer | Vincent Song <vincent.wsong@gmail.com> | 2016-06-10 15:16:45 -0400 |
commit | 247c3fe200d11b709a88215581332f6150da765e (patch) | |
tree | 576bbb2ed0c64c78362e34e11e67cbd9d413ca25 | |
parent | f25891ef02941ac3333a16930fbc2b562d0c96b9 (diff) | |
download | php-sparkpost-247c3fe200d11b709a88215581332f6150da765e.zip php-sparkpost-247c3fe200d11b709a88215581332f6150da765e.tar.gz php-sparkpost-247c3fe200d11b709a88215581332f6150da765e.tar.bz2 |
Resource.post and get now accepts CC headers which are generated in the fixCarbonCopy() method
-rw-r--r-- | lib/SparkPost/Resource.php | 8 | ||||
-rw-r--r-- | lib/SparkPost/Transmission.php | 35 |
2 files changed, 24 insertions, 19 deletions
diff --git a/lib/SparkPost/Resource.php b/lib/SparkPost/Resource.php index d08a388..57dfd24 100644 --- a/lib/SparkPost/Resource.php +++ b/lib/SparkPost/Resource.php @@ -13,14 +13,14 @@ class Resource $this->endpoint = $endpoint; } - public function get($uri, $payload) + public function get($uri, $payload, $header) { - return $this->sparkpost->request('GET', $this->endpoint.'/'.$uri, $payload); + return $this->sparkpost->request('GET', $this->endpoint.'/'.$uri, $payload, $header); } - public function post($payload) + public function post($payload, $header) { echo $payload; - return $this->sparkpost->request('POST', $endpoint, $payload); + return $this->sparkpost->request('POST', $this->endpoint, $payload, $header); } } diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index 82b438c..caffe45 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -2,13 +2,20 @@ namespace SparkPost; +require '../../vendor/autoload.php'; + class Transmission extends Resource { protected $endpoint = 'transmissions'; + protected $customHeaders = array(); - public function __construct(SparkPost $sparkpost) - { - parent::__construct($sparkpost, $endpoint); +// public function __construct(SparkPost $sparkpost) +// { +// parent::__construct($sparkpost, $endpoint); +// } + + public function __construct(){ + } public function fixBlindCarbonCopy($payload) @@ -78,20 +85,15 @@ class Transmission extends Resource $ccCustomHeadersList = $ccCustomHeadersList . ' ' . $ccRecipient['address']; } - array_push($recipientsList, $newRecipient); } - //Creates customHeaders and adds CSV list of CC emails - $customHeaders = array("CC" => $ccCustomHeadersList); - $modifiedPayload['customHeaders'] = $customHeaders; + if(!empty($ccCustomHeadersList)){ //If there are CC'd people + $this->customHeaders = array("CC" => $ccCustomHeadersList); + } + //Edits customHeaders and adds array of CSV list of CC emails + } - - - //Creates customHeaders and adds CSV list of CC emails - $customHeaders = array("CC" => $ccCustomHeadersList); - $modifiedPayload['customHeaders'] = $customHeaders; - //delete CC unset($modifiedPayload['cc']); @@ -102,6 +104,9 @@ class Transmission extends Resource { $modifiedPayload = $this->fixBlindCarbonCopy($payload); //Accounts for any BCCs $modifiedPayload = $this->fixCarbonCopy($modifiedPayload); //Accounts for any CCs - return parent::post($modifiedPayload); + //return parent::post($modifiedPayload, $this->customHeaders); } -}
\ No newline at end of file +} +]; + +?>
\ No newline at end of file |