summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanil zakablukovskii <danil.kabluk@gmail.com>2016-02-27 17:17:00 +0100
committerJason Rhodes <jason.matthew.rhodes@gmail.com>2016-02-28 16:59:59 -0500
commit286f9be997413352c4f4d5abcff98a2dbbc2293b (patch)
tree7ccfe2c685bf2f86085d2a1d4694671cdee96afd
parentf4ed2228821f3aa3357bd522489c7d1ce3c7e960 (diff)
downloadphp-sparkpost-286f9be997413352c4f4d5abcff98a2dbbc2293b.zip
php-sparkpost-286f9be997413352c4f4d5abcff98a2dbbc2293b.tar.gz
php-sparkpost-286f9be997413352c4f4d5abcff98a2dbbc2293b.tar.bz2
removed test, because it's not needed after added strong-typing to the 'setHttpAdapter' method
-rw-r--r--composer.json2
-rw-r--r--lib/SendGridCompatibility/Email.php133
-rw-r--r--lib/SendGridCompatibility/SendGrid.php14
-rw-r--r--lib/SparkPost/APIResource.php104
-rw-r--r--lib/SparkPost/APIResponseException.php3
-rw-r--r--lib/SparkPost/SparkPost.php61
-rw-r--r--lib/SparkPost/Transmission.php81
-rw-r--r--test/unit/SparkPostTest.php13
8 files changed, 162 insertions, 249 deletions
diff --git a/composer.json b/composer.json
index 3c9d0ee..045b260 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "sparkpost/php-sparkpost",
"description": "Client library for interfacing with the SparkPost API.",
"license": "Apache 2.0",
- "version": "1.0.1",
+ "version": "1.0.2",
"authors": [
{
"name": "Message Systems, Inc."
diff --git a/lib/SendGridCompatibility/Email.php b/lib/SendGridCompatibility/Email.php
index b375839..5065e1f 100644
--- a/lib/SendGridCompatibility/Email.php
+++ b/lib/SendGridCompatibility/Email.php
@@ -1,181 +1,146 @@
<?php
namespace SparkPost\SendGridCompatibility;
-class Email
-{
+class Email {
public $model;
/**
* Sets up the model for saving the configuration
*/
- public function __construct()
- {
+ public function __construct() {
$this->model = array();
}
/**
- * Adds addresses as recipients
- *
+ * adds addresses as recipients
* @param string $address
* @param string $name optional
- * @return \SparkPost\SendGridCompatibility\Email
+ * @return $this
*/
- public function addTo($address, $name = null)
- {
+ public function addTo($address, $name = null) {
if (!isset($this->model['recipients'])) {
$this->model['recipients'] = array();
}
- if (isset($name)) {
- $address = array('address' => array('email' => $address, 'name' => $name));
+ if(isset($name)) {
+ $address = array('address'=>array('email'=>$address, 'name'=>$name));
} else {
- $address = array('address' => array('email' => $address));
+ $address = array('address'=>array('email'=>$address));
}
array_push($this->model['recipients'], $address);
-
return $this;
}
/**
- * Explicitly sets a list of addresses
- *
- * @param array $addresses
- * @return \SparkPost\SendGridCompatibility\Email
- */
- public function setTos(array $addresses)
- {
+ * explicitly sets a list of addresses
+ * @param array $addresses
+ * @return $this
+ */
+ public function setTos(array $addresses) {
$this->model['recipients'] = $addresses;
-
return $this;
}
/**
- * Sets the from address
- *
+ * sets the from address
* @param string $address
* @return $this
*/
- public function setFrom($address)
- {
+ public function setFrom($address) {
$this->model['from'] = array('email' => $address);
-
return $this;
}
/**
* Sets the name for the from address
- *
* @param string $name
* @return $this
* @throws \Exception
*/
- public function setFromName($name)
- {
- if (!isset($this->model['from'])) {
+ public function setFromName($name) {
+ if(!isset($this->model['from'])){
throw new \Exception('Must set \'From\' prior to setting \'From Name\'.');
}
$this->model['from']['name'] = $name;
-
return $this;
}
/**
- * Sets the reply to field
- *
+ * sets the reply to field
* @param string $address
* @return $this
*/
- public function setReplyTo($address)
- {
+ public function setReplyTo ($address) {
$this->model['replyTo'] = $address;
-
return $this;
}
/**
- * Throws an error because bcc fields are not yet implemented
- *
+ * throws an error because bcc fields are not yet implemented.
* @throws \Exception
* @param string $address
* @return $this
*/
- public function addBcc($address)
- {
+ public function addBcc($address) {
throw new \Exception('Adding bcc recipients is not yet supported, try adding them as a \'to\' address');
}
/**
- * Sets the subject header
- *
+ * sets the subject header
* @param string $subject
- * @return \SparkPost\SendGridCompatibility\Email
+ * @return $this
*/
- public function setSubject($subject)
- {
+ public function setSubject($subject) {
$this->model['subject'] = $subject;
-
return $this;
}
/**
- * Sets the text body
- *
+ * sets the text body
* @param string $text
- * @return \SparkPost\SendGridCompatibility\Email
+ * @return $this
*/
- public function setText($text)
- {
+ public function setText($text) {
$this->model['text'] = $text;
-
return $this;
}
/**
- * Sets the html body
- *
+ * sets the html body
* @param string $html
- * @return \SparkPost\SendGridCompatibility\Email
+ * @return $this
*/
- public function setHtml($html)
- {
+ public function setHtml($html) {
$this->model['html'] = $html;
-
return $this;
}
/**
* Throws an exception since adding categories is not yet supported
- *
- * @throws \Exception
* @param string $category
* @throws \Exception
*/
- public function addCategory($category)
- {
+ public function addCategory($category) {
throw new \Exception('Adding categories is not yet supported');
}
/**
* Throws an exception since adding attachments is not yet supported
- *
- * @param mixed $attachment
* @throws \Exception
+ * @param mixed $attachment
*/
- public function addAttachment($attachment)
- {
+ public function addAttachment($attachment) {
throw new \Exception('Adding attachments is not yet supported');
}
/**
* Adds transmission level substitution data
- *
* @param string $name
* @param mixed $values
- * @return \SparkPost\SendGridCompatibility\Email
+ * @return $this
*/
- public function addSubstitution($name, $values)
- {
+ public function addSubstitution($name, $values) {
if (!isset($this->model['substitutionData'])) {
$this->model['substitutionData'] = array();
}
@@ -186,46 +151,37 @@ class Email
/**
* Adds transmission level substitution data
- *
* @param string $name
* @param mixed $values
*/
- public function addSection($name, $values)
- {
+ public function addSection($name, $values) {
$this->addSubstitution($name, $values);
}
/**
* Throws an exception because arguments for third party systems is not supported
- *
- * @param $key
- * @param mixed $value
* @throws \Exception
+ * @param mixed $value
*/
- public function addUniqueArg($key, $value)
- {
+ public function addUniqueArg($key, $value) {
throw new \Exception('Adding Unique Arguments is not yet supported');
}
/**
* Throws an exception because arguments for third party systems is not supported
- *
- * @param mixed $values
* @throws \Exception
+ * @param mixed $values
*/
- public function setUniqueArgs(array $values)
- {
+ public function setUniqueArgs(array $values) {
throw new \Exception('Setting Unique Arguments is not yet supported');
}
/**
* Adds custom headers to the email header
- *
* @param string $name
* @param string $value
*/
- public function addHeader($name, $value)
- {
+ public function addHeader($name, $value) {
if (!isset($this->model['customHeaders'])) {
$this->model['customHeaders'] = array();
}
@@ -233,14 +189,11 @@ class Email
}
/**
- * Converts this object to a configuration for a SparkPost transmission
- *
+ * converts this object to a configuration for a SparkPost transmission
* @return array
*/
- public function toSparkPostTransmission()
- {
+ public function toSparkPostTransmission() {
return $this->model;
}
}
-
?>
diff --git a/lib/SendGridCompatibility/SendGrid.php b/lib/SendGridCompatibility/SendGrid.php
index e5b21e6..1671e6b 100644
--- a/lib/SendGridCompatibility/SendGrid.php
+++ b/lib/SendGridCompatibility/SendGrid.php
@@ -3,14 +3,12 @@ namespace SparkPost\SendGridCompatibility;
use SparkPost\SparkPost;
-class SendGrid
-{
+class SendGrid{
private $sparky;
- public function __construct($username, $password, $options = null, $httpAdapter)
- {
- // username isn't used in our system
- $opts = array('key' => $password);
+ public function __construct($username, $password, $options = null, $httpAdapter) {
+ //username isn't used in our system
+ $opts = array('key'=>$password);
if (!is_null($options)) {
$opts = array_merge($opts, $options);
}
@@ -18,10 +16,8 @@ class SendGrid
$this->sparky = new SparkPost($httpAdapter, $opts);
}
- public function send(Email $email)
- {
+ public function send(Email $email) {
$this->sparky->transmission->send($email->toSparkPostTransmission());
}
}
-
?>
diff --git a/lib/SparkPost/APIResource.php b/lib/SparkPost/APIResource.php
index 0677b38..d02b91e 100644
--- a/lib/SparkPost/APIResource.php
+++ b/lib/SparkPost/APIResource.php
@@ -4,12 +4,12 @@ namespace SparkPost;
/**
* SDK interface for managing SparkPost API endpoints
*/
-class APIResource
-{
+class APIResource {
/**
- * Name of the API endpoint, mainly used for URL construction.
+ * name of the API endpoint, mainly used for URL construction.
* This is public to provide an interface
+ *
* @var string
*/
public $endpoint;
@@ -33,11 +33,9 @@ class APIResource
/**
* Initializes config and httpAdapter for use later.
- *
* @param $sparkpost \SparkPost\SparkPost provides api configuration information
*/
- public function __construct(SparkPost $sparkpost)
- {
+ public function __construct(SparkPost $sparkpost) {
$this->sparkpost = $sparkpost;
}
@@ -48,14 +46,13 @@ class APIResource
* @param string $mapKey a dot syntax path determining which value to set
* @param mixed $value value for the given path
*/
- protected function setMappedValue(&$model, $mapKey, $value)
- {
- // get mapping
- if (empty(static::$parameterMappings)) {
+ protected function setMappedValue(&$model, $mapKey, $value) {
+ //get mapping
+ if( empty(static::$parameterMappings) ) {
// if parameterMappings is empty we can assume that no wrapper is defined
// for the current endpoint and we will use the mapKey to define the mappings directly
$mapPath = $mapKey;
- } elseif (array_key_exists($mapKey, static::$parameterMappings)) {
+ }elseif(array_key_exists($mapKey, static::$parameterMappings)) {
// use only defined parameter mappings to construct $model
$mapPath = static::$parameterMappings[$mapKey];
} else {
@@ -64,52 +61,47 @@ class APIResource
$path = explode('.', $mapPath);
$temp = &$model;
- foreach ($path as $key) {
- if (!isset($temp[$key])) {
+ foreach( $path as $key ) {
+ if( !isset($temp[$key]) ){
$temp[$key] = null;
}
$temp = &$temp[$key];
}
$temp = $value;
+
}
/**
- * Maps values from the passed in model to those needed for the request
- *
+ * maps values from the passed in model to those needed for the request
* @param array $requestConfig the passed in model
* @param array $model the set of defaults
* @return array A model ready for the body of a request
*/
- protected function buildRequestModel(array $requestConfig, array $model = [])
- {
- foreach ($requestConfig as $key => $value) {
+ protected function buildRequestModel(Array $requestConfig, Array $model=[] ) {
+ foreach($requestConfig as $key => $value) {
$this->setMappedValue($model, $key, $value);
}
-
return $model;
}
/**
- * Posts to the api with a supplied body
- *
+ * posts to the api with a supplied body
* @param array $body post body for the request
* @return array Result of the request
*/
- public function create(array $body = [])
- {
- return $this->callResource('post', null, ['body' => $body]);
+ public function create(Array $body=[]) {
+ return $this->callResource( 'post', null, ['body'=>$body]);
}
/**
* Makes a put request to the api with a supplied body
- *
- * @param string $resourcePath string resource path of specific resource
+ * @param $resourcePath
* @param array $body Put body for the request
* @return array Result of the request
+ * @throws APIResponseException
*/
- public function update($resourcePath, array $body = [])
- {
- return $this->callResource('put', $resourcePath, ['body' => $body]);
+ public function update( $resourcePath, Array $body=[]) {
+ return $this->callResource( 'put', $resourcePath, ['body'=>$body]);
}
/**
@@ -119,9 +111,8 @@ class APIResource
* @param array $query (optional) query string parameters
* @return array Result of the request
*/
- public function get($resourcePath = null, array $query = [])
- {
- return $this->callResource('get', $resourcePath, ['query' => $query]);
+ public function get( $resourcePath=null, Array $query=[] ) {
+ return $this->callResource( 'get', $resourcePath, ['query'=>$query] );
}
/**
@@ -131,48 +122,44 @@ class APIResource
* @param array $query (optional) query string parameters
* @return array Result of the request
*/
- public function delete($resourcePath = null, array $query = [])
- {
- return $this->callResource('delete', $resourcePath, ['query' => $query]);
+ public function delete( $resourcePath=null, Array $query=[] ) {
+ return $this->callResource( 'delete', $resourcePath, ['query'=>$query] );
}
+
/**
- * Assembles a URL for a request
- *
+ * assembles a URL for a request
* @param string $resourcePath path after the initial endpoint
* @param array $options array with an optional value of query with values to build a querystring from.
* @return string the assembled URL
*/
- private function buildUrl($resourcePath, $options)
- {
+ private function buildUrl($resourcePath, $options) {
$url = "/{$this->endpoint}/";
- if (!is_null($resourcePath)) {
+ if (!is_null($resourcePath)){
$url .= $resourcePath;
}
- if (!empty($options['query'])) {
+ if( !empty($options['query'])) {
$queryString = http_build_query($options['query']);
- $url .= '?' . $queryString;
+ $url .= '?'.$queryString;
}
return $url;
}
+
/**
* Prepares a body for put and post requests
- *
* @param array $options array with an optional value of body with values to build a request body from.
* @return string|null A json encoded string or null if no body was provided
*/
- private function buildBody($options)
- {
+ private function buildBody($options) {
$body = null;
- if (!empty($options['body'])) {
+ if( !empty($options['body']) ) {
$model = static::$structure;
- $requestModel = $this->buildRequestModel($options['body'], $model);
+ $requestModel = $this->buildRequestModel( $options['body'], $model );
$body = json_encode($requestModel);
}
-
return $body;
}
@@ -190,14 +177,13 @@ class APIResource
* @return array Result set of action performed on resource
* @throws APIResponseException
*/
- private function callResource($action, $resourcePath = null, $options = [])
- {
+ private function callResource( $action, $resourcePath=null, $options=[] ) {
$action = strtoupper($action); // normalize
$url = $this->buildUrl($resourcePath, $options);
$body = $this->buildBody($options);
- // make request
+ //make request
try {
$response = $this->sparkpost->httpAdapter->send($url, $action, $this->sparkpost->getHttpHeaders(), $body);
@@ -210,16 +196,20 @@ class APIResource
if ($statusCode === 404) {
throw new APIResponseException('The specified resource does not exist', 404);
}
- throw new APIResponseException('Received bad response from ' . ucfirst($this->endpoint) . ' API: ' .
- $statusCode);
+ throw new APIResponseException('Received bad response from ' . ucfirst($this->endpoint) . ' API: '. $statusCode );
}
- } catch (\Exception $exception) { // Configuration Errors, and a catch all for other errors
- if ($exception instanceof APIResponseException) {
+ }
+
+ /*
+ * Configuration Errors, and a catch all for other errors
+ */
+ catch (\Exception $exception) {
+ if($exception instanceof APIResponseException) {
throw $exception;
}
- throw new APIResponseException('Unable to contact ' . ucfirst($this->endpoint) . ' API: ' .
- $exception->getMessage());
+ throw new APIResponseException('Unable to contact ' . ucfirst($this->endpoint) . ' API: '. $exception->getMessage());
}
}
+
}
diff --git a/lib/SparkPost/APIResponseException.php b/lib/SparkPost/APIResponseException.php
index e279e4d..cc0842c 100644
--- a/lib/SparkPost/APIResponseException.php
+++ b/lib/SparkPost/APIResponseException.php
@@ -2,8 +2,7 @@
namespace SparkPost;
-class APIResponseException extends \Exception
-{
+class APIResponseException extends \Exception {
}
diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php
index 13d947c..46623c9 100644
--- a/lib/SparkPost/SparkPost.php
+++ b/lib/SparkPost/SparkPost.php
@@ -1,16 +1,14 @@
<?php
namespace SparkPost;
-
use Ivory\HttpAdapter\Configuration;
use Ivory\HttpAdapter\HttpAdapterInterface;
-class SparkPost
-{
+class SparkPost {
+
public $transmission;
/**
- * Connection config for making requests
- * @var array
+ * Connection config for making requests.
*/
private $config;
@@ -23,12 +21,12 @@ class SparkPost
* Default config values. Passed in values will override these.
*/
private static $apiDefaults = [
- 'host' => 'api.sparkpost.com',
- 'protocol' => 'https',
- 'port' => 443,
- 'strictSSL' => true,
- 'key' => '',
- 'version' => 'v1'
+ 'host'=>'api.sparkpost.com',
+ 'protocol'=>'https',
+ 'port'=>443,
+ 'strictSSL'=>true,
+ 'key'=>'',
+ 'version'=>'v1'
];
/**
@@ -37,12 +35,11 @@ class SparkPost
* Sets up instances of sub libraries.
*
* @param \Ivory\HttpAdapter\HttpAdapterInterface $httpAdapter - An adapter for making http requests
- * @param string | array $settingsConfig - Hashmap that contains config values
+ * @param String | array $settingsConfig - Hashmap that contains config values
* for the SDK to connect to SparkPost. If its a string we assume that
* its just they API Key.
*/
- public function __construct($httpAdapter, $settingsConfig)
- {
+ public function __construct($httpAdapter, $settingsConfig) {
//config needs to be setup before adapter because of default adapter settings
$this->setConfig($settingsConfig);
$this->setHttpAdapter($httpAdapter);
@@ -53,12 +50,10 @@ class SparkPost
/**
* Creates an unwrapped api interface for endpoints that aren't yet supported.
* The new resource is attached to this object as well as returned
- *
* @param string $endpoint
* @return APIResource - the unwrapped resource
*/
- public function setupUnwrapped($endpoint)
- {
+ public function setupUnwrapped ($endpoint) {
$this->{$endpoint} = new APIResource($this);
$this->{$endpoint}->endpoint = $endpoint;
@@ -68,11 +63,10 @@ class SparkPost
/**
* Merges passed in headers with default headers for http requests
*/
- public function getHttpHeaders()
- {
+ public function getHttpHeaders() {
$defaultOptions = [
- 'Authorization' => $this->config['key'],
- 'Content-Type' => 'application/json',
+ 'Authorization' => $this->config['key'],
+ 'Content-Type' => 'application/json',
];
return $defaultOptions;
@@ -80,55 +74,48 @@ class SparkPost
/**
* Helper function for getting the configuration for http requests
- *
* @param array $config
* @return Configuration
*/
- private function getHttpConfig(array $config)
- {
+ private function getHttpConfig($config) {
// get composer.json to extract version number
$composerFile = file_get_contents(dirname(__FILE__) . '/../../composer.json');
$composer = json_decode($composerFile, true);
// create Configuration for http adapter
$httpConfig = new Configuration();
- $baseUrl = $config['protocol'] . '://' . $config['host'] . ($config['port'] ? ':' . $config['port'] : '') .
- '/api/' . $config['version'];
+ $baseUrl = $config['protocol'] . '://' . $config['host'] . ($config['port'] ? ':' . $config['port'] : '') . '/api/' . $config['version'];
$httpConfig->setBaseUri($baseUrl);
$httpConfig->setUserAgent('php-sparkpost/' . $composer['version']);
-
return $httpConfig;
}
+
/**
* Validates and sets up the httpAdapter
- *
* @param $httpAdapter \Ivory\HttpAdapter\HttpAdapterInterface to make requests through.
* @throws \Exception
*/
- public function setHttpAdapter(HttpAdapterInterface $httpAdapter)
- {
+ public function setHttpAdapter(HttpAdapterInterface $httpAdapter) {
$this->httpAdapter = $httpAdapter;
$this->httpAdapter->setConfiguration($this->getHttpConfig($this->config));
}
/**
* Allows the user to pass in values to override the defaults and set their API key
- *
- * @param string | array $settingsConfig - Hashmap that contains config values
+ * @param String | array $settingsConfig - Hashmap that contains config values
* for the SDK to connect to SparkPost. If its a string we assume that
* its just they API Key.
* @throws \Exception
*/
- public function setConfig($settingsConfig)
- {
+ public function setConfig($settingsConfig) {
// if the config map is a string we should assume that its an api key
if (is_string($settingsConfig)) {
- $settingsConfig = ['key' => $settingsConfig];
+ $settingsConfig = ['key'=>$settingsConfig];
}
// Validate API key because its required
- if (!isset($settingsConfig['key']) || empty(trim($settingsConfig['key']))) {
+ if (!isset($settingsConfig['key']) || empty(trim($settingsConfig['key']))){
throw new \Exception('You must provide an API key');
}
@@ -136,7 +123,7 @@ class SparkPost
// set config, overriding defaults
foreach ($settingsConfig as $configOption => $configValue) {
- if (key_exists($configOption, $this->config)) {
+ if(key_exists($configOption, $this->config)) {
$this->config[$configOption] = $configValue;
}
}
diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php
index bbd1ca9..6beb087 100644
--- a/lib/SparkPost/Transmission.php
+++ b/lib/SparkPost/Transmission.php
@@ -1,11 +1,13 @@
<?php
namespace SparkPost;
+use Guzzle\Http\Client;
+use Guzzle\Http\Exception\ClientErrorResponseException;
/**
* SDK interface for managing transmissions
*/
-class Transmission extends APIResource
-{
+class Transmission extends APIResource {
+
public $endpoint = 'transmissions';
/**
@@ -13,24 +15,24 @@ class Transmission extends APIResource
* @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'
];
/**
@@ -38,13 +40,13 @@ class Transmission extends APIResource
* @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
];
/**
@@ -72,11 +74,10 @@ class Transmission extends APIResource
* 'useDraftTemplate': boolean
*
* @param array $transmissionConfig
- * @return array API response represented as key-value pairs
+ * @return array API repsonse represented as key-value pairs
*/
- public function send(array $transmissionConfig)
- {
- return $this->create($transmissionConfig);
+ public function send( $transmissionConfig ) {
+ return $this->create( $transmissionConfig );
}
/**
@@ -87,28 +88,22 @@ class Transmission extends APIResource
* @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 );
}
/**
* Method for retrieving information about a single transmission
- * Wrapper method for a cleaner interface
- *
+ * 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);
}
}
diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php
index b1b38fe..ed10b55 100644
--- a/test/unit/SparkPostTest.php
+++ b/test/unit/SparkPostTest.php
@@ -1,15 +1,16 @@
<?php
namespace SparkPost\Test;
-use SparkPost\SparkPost;
use Ivory\HttpAdapter\CurlHttpAdapter;
+use Mockery;
+use SparkPost\SparkPost;
use SparkPost\Test\TestUtils\ClassUtils;
-use \Mockery;
class SparkPostTest extends \PHPUnit_Framework_TestCase {
private static $utils;
private $adapterMock;
+ /** @var SparkPost */
private $resource;
/**
@@ -43,14 +44,6 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase {
$this->assertRegExp('/php-sparkpost.*/', $adapter->getConfiguration()->getUserAgent());
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessageRegExp /valid Ivory\\HttpAdapter/
- */
- public function testSetBadHTTPAdapter() {
- $this->resource->setHttpAdapter(new \stdClass());
- }
-
public function testSetConfigStringKey() {
$this->resource->setConfig('a key');
$config = self::$utils->getProperty($this->resource, 'config');