diff options
-rw-r--r-- | examples/transmission/get_all_transmissions.php | 4 | ||||
-rw-r--r-- | examples/transmission/get_transmission.php | 6 | ||||
-rw-r--r-- | examples/transmission/rfc822.php | 6 | ||||
-rw-r--r-- | examples/transmission/send_transmission_all_fields.php | 7 | ||||
-rw-r--r-- | examples/transmission/simple_send.php | 6 | ||||
-rw-r--r-- | examples/transmission/stored_recipients_inline_content.php | 4 | ||||
-rw-r--r-- | examples/transmission/stored_template_send.php | 8 | ||||
-rw-r--r-- | examples/unwrapped/create_template.php | 11 | ||||
-rw-r--r-- | lib/SendGridCompatibility/SendGrid.php | 16 | ||||
-rw-r--r-- | lib/SparkPost/APIResource.php | 218 | ||||
-rw-r--r-- | lib/SparkPost/SparkPost.php | 132 | ||||
-rw-r--r-- | lib/SparkPost/Transmission.php | 28 |
12 files changed, 233 insertions, 213 deletions
diff --git a/examples/transmission/get_all_transmissions.php b/examples/transmission/get_all_transmissions.php index 1e1882b..669c3e7 100644 --- a/examples/transmission/get_all_transmissions.php +++ b/examples/transmission/get_all_transmissions.php @@ -9,10 +9,10 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::all(); + $results = $sparky->transmission->all(); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/get_transmission.php b/examples/transmission/get_transmission.php index 84cd227..5882a49 100644 --- a/examples/transmission/get_transmission.php +++ b/examples/transmission/get_transmission.php @@ -1,6 +1,7 @@ <?php namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); + use SparkPost\SparkPost; use SparkPost\Transmission; use GuzzleHttp\Client; @@ -8,11 +9,10 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); - +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::find('Your Transmission ID'); + $results = $sparky->transmission->find('Your Transmission ID'); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/rfc822.php b/examples/transmission/rfc822.php index ec932e7..cb88471 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.php @@ -8,15 +8,15 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send([ + $results = $sparky->transmission->send([ 'recipients'=>[ [ 'address'=>[ 'email'=>'john.doe@example.com' - ] + ] ] ], 'rfc822'=>"Content-Type: text/plain\nFrom: From Envelope <from@sparkpostbox.com>\nSubject: Example Email\n\nHello World" diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php index 3bd9315..be82b97 100644 --- a/examples/transmission/send_transmission_all_fields.php +++ b/examples/transmission/send_transmission_all_fields.php @@ -8,12 +8,12 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); // TODO: update all from emails to = sandbox domain try{ - $results = Transmission::send([ + $results = $sparky->transmission->send([ "campaign"=>"my-campaign", "metadata"=>[ "sample_campaign"=>true, @@ -37,12 +37,11 @@ try{ [ "address"=>[ "email"=>"john.doe@example.com" - ] + ] ] ] ]); - var_dump($results); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/simple_send.php b/examples/transmission/simple_send.php index caaf962..2edfbf6 100644 --- a/examples/transmission/simple_send.php +++ b/examples/transmission/simple_send.php @@ -9,10 +9,10 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send([ + $results = $sparky->transmission->send([ "from"=>"From Envelope <from@sparkpostbox.com>", "html"=>"<p>Hello World!</p>", "text"=>"Hello World!", @@ -21,7 +21,7 @@ try { [ "address"=>[ "email"=>"john.doe@example.com" - ] + ] ] ] ]); diff --git a/examples/transmission/stored_recipients_inline_content.php b/examples/transmission/stored_recipients_inline_content.php index 42e40df..853030d 100644 --- a/examples/transmission/stored_recipients_inline_content.php +++ b/examples/transmission/stored_recipients_inline_content.php @@ -8,11 +8,11 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send([ + $results = $sparky->transmission->send([ "campaign"=>"my-campaign", "from"=>"From Envelope <from@sparkpostbox.com>", "html"=>"<p>Hello World! Your name is: {{name}}</p>", diff --git a/examples/transmission/stored_template_send.php b/examples/transmission/stored_template_send.php index 82be209..3d52f0a 100644 --- a/examples/transmission/stored_template_send.php +++ b/examples/transmission/stored_template_send.php @@ -8,19 +8,19 @@ use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$sparky = new SparkPost($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send([ + $results = $sparky->transmission->send([ "from"=>"From Envelope <from@sparkpostbox.com>", "recipients"=>[ [ "address"=>[ "email"=>"john.doe@example.com" - ] + ] ] ], - "template"=>"my-template" + "template"=>"my-first-email" ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { diff --git a/examples/unwrapped/create_template.php b/examples/unwrapped/create_template.php index ee4ff6c..b092340 100644 --- a/examples/unwrapped/create_template.php +++ b/examples/unwrapped/create_template.php @@ -1,30 +1,27 @@ <?php namespace Examples\Unwrapped; require_once (dirname(__FILE__).'/../bootstrap.php'); -use SparkPost\SparkPost; -use SparkPost\APIResource; use GuzzleHttp\Client; use Ivory\HttpAdapter\Guzzle6HttpAdapter; $key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::configure($httpAdapter, ['key'=>$key]); +$resource = new \SparkPost\APIResource($httpAdapter, ['key'=>$key]); try { // define the endpoint - APIResource::$endpoint = 'templates'; + $resource->endpoint = 'templates'; $templateConfig = [ 'name' => 'Summer Sale!', 'id'=>'summer-sale', 'content'=> [ - 'from' => 'john.doe@sparkpostbox.com', + 'from' => 'from@sparkpostbox.com', 'subject' => 'Summer deals', 'html' => '<b>Check out these deals!</b>' ] ]; - $results = APIResource::create($templateConfig); - var_dump($results); + $results = $resource->create($templateConfig); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/lib/SendGridCompatibility/SendGrid.php b/lib/SendGridCompatibility/SendGrid.php index a85337a..b92457b 100644 --- a/lib/SendGridCompatibility/SendGrid.php +++ b/lib/SendGridCompatibility/SendGrid.php @@ -1,22 +1,24 @@ <?php namespace SparkPost\SendGridCompatibility; -use SparkPost\Transmission; +use SparkPost\SparkPost; use SparkPost\SendGridCompatibility\Email; -use SparkPost\Configuration; class SendGrid{ - public function __construct($username, $password, $options = null) { + private $sparky; + + 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); } - Configuration::setConfig($opts); + + $this->sparky = new SparkPost($httpAdapter, $opts); } - + public function send(Email $email) { - Trasmission::send($email->toSparkPostTransmission()); + $this->sparky->transmission->send($email->toSparkPostTransmission()); } } -?>
\ No newline at end of file +?> diff --git a/lib/SparkPost/APIResource.php b/lib/SparkPost/APIResource.php index 260d5e2..21514dc 100644 --- a/lib/SparkPost/APIResource.php +++ b/lib/SparkPost/APIResource.php @@ -1,5 +1,7 @@ <?php namespace SparkPost; +use Ivory\HttpAdapter\Configuration; +use Ivory\HttpAdapter\HttpAdapterInterface; use Ivory\HttpAdapter\HttpAdapterException; /** @@ -9,31 +11,152 @@ class APIResource { /** * @desc name of the API endpoint, mainly used for URL construction. + * This is public to provide an interface + * * @var string */ - public static $endpoint; + public $endpoint; /** * @desc Mapping for values passed into the send method to the values needed for the respective API * @var array */ - protected static $parameterMappings = array(); + protected static $parameterMappings = []; /** * @desc Sets up default structure and default values for the model that is acceptable by the API * @var array */ - protected static $structure = array(); + protected static $structure = []; + + /** + * TODO: Docs + */ + private $config; + + /** + * TODO: Docs + */ + private $httpAdapter; + + /** + * TODO: Docs + */ + private static $apiDefaults = [ + 'host'=>'api.sparkpost.com', + 'protocol'=>'https', + 'port'=>443, + 'strictSSL'=>true, + 'key'=>'', + 'version'=>'v1' + ]; + + /** + * @desc TODO: Docs + */ + public function __construct($httpAdapter, $config) { + //config needs to be setup before adapter because of default adapter settings + $this->setConfig($config); + $this->setHttpAdapter($httpAdapter); + } + + /** + * @desc Merges passed in headers with default headers for http requests + * @return Array - headers to be set on http requests + */ + private function getHttpHeaders(Array $headers = null) { + $defaultOptions = [ + 'Authorization' => $this->config['key'], + 'Content-Type' => 'application/json', + ]; + + // Merge passed in headers with defaults + if (!is_null($headers)) { + foreach ($headers as $header => $value) { + $defaultOptions[$header] = $value; + } + } + return $defaultOptions; + } + + + /** + * @desc Helper function for getting the configuration for http requests + * @return \Ivory\HttpAdapter\Configuration + */ + // TODO: Need to figure out how to set strictSSL + 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']; + $httpConfig->setBaseUri($baseUrl); + $httpConfig->setUserAgent('php-sparkpost/' . $composer['version']); + return $httpConfig; + } + + /** + * TODO: Docs + */ + public function setHttpAdapter($httpAdapter) { + if (!$httpAdapter instanceOf HttpAdapterInterface) { + throw new \Exception('$httpAdapter paramter must be a valid Ivory\HttpAdapter'); + } + + $this->httpAdapter = $httpAdapter; + $this->httpAdapter->setConfiguration($this->getHttpConfig($this->config)); + } /** - * @desc Ensure that this class cannot be instansiated + * Retrieves the Http Adapter that was previously setup by the user + * @throws \Exception */ - private function __construct() {} + public function getHttpAdapter() { + if ($this->httpAdapter === null) { + throw new \Exception('No Http Adapter has been provided'); + } + return $this->httpAdapter; + } + + /** + * Allows the user to pass in values to override the defaults and set their API key + * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost + * @throws \Exception + */ + public function setConfig(Array $settingsConfig) { + // Validate API key because its required + if (!isset($settingsConfig['key']) || empty(trim($settingsConfig['key']))){ + throw new \Exception('You must provide an API key'); + } + + $this->config = self::$apiDefaults; + + // set config, overriding defaults + foreach ($settingsConfig as $configOption => $configValue) { + if(key_exists($configOption, $this->config)) { + $this->config[$configOption] = $configValue; + } + } + } + + /** + * Retrieves the configuration that was previously setup by the user + * @throws \Exception + */ + public function getConfig() { + if ($this->config === null) { + throw new \Exception('No configuration has been provided'); + } + return $this->config; + } /** * @desc Private Method helper to reference parameter mappings and set the right value for the right parameter */ - protected static function setMappedValue (&$model, $mapKey, $value) { + protected function setMappedValue (&$model, $mapKey, $value) { //get mapping if( empty(static::$parameterMappings) ) { // if parameterMappings is empty we can assume that no wrapper is defined @@ -61,9 +184,9 @@ class APIResource { /** * TODO: Docs */ - protected static function buildRequestModel(Array $requestConfig, Array $model=[] ) { - foreach($requestConfig as $key=>$value) { - self::setMappedValue($model, $key, $value); + protected function buildRequestModel(Array $requestConfig, Array $model=[] ) { + foreach($requestConfig as $key => $value) { + $this->setMappedValue($model, $key, $value); } return $model; } @@ -71,15 +194,15 @@ class APIResource { /** * TODO: Docs */ - public static function create(Array $body=[]) { - return self::callResource( 'post', null, ['body'=>$body]); + public function create(Array $body=[]) { + return $this->callResource( 'post', null, ['body'=>$body]); } /** * TODO: Docs */ - public static function update( $resourcePath, Array $body=[]) { - return self::callResource( 'put', $resourcePath, ['body'=>$body]); + public function update( $resourcePath, Array $body=[]) { + return $this->callResource( 'put', $resourcePath, ['body'=>$body]); } /** @@ -89,8 +212,8 @@ class APIResource { * @param array $options (optional) query string parameters * @return array Result set of transmissions found */ - public static function get( $resourcePath=null, Array $query=[] ) { - return self::callResource( 'get', $resourcePath, ['query'=>$query] ); + public function get( $resourcePath=null, Array $query=[] ) { + return $this->callResource( 'get', $resourcePath, ['query'=>$query] ); } /** @@ -100,10 +223,43 @@ class APIResource { * @param array $options (optional) query string parameters * @return array Result set of transmissions found */ - public static function delete( $resourcePath=null, Array $query=[] ) { - return self::callResource( 'delete', $resourcePath, ['query'=>$query] ); + public function delete( $resourcePath=null, Array $query=[] ) { + return $this->callResource( 'delete', $resourcePath, ['query'=>$query] ); } + + /** + * TODO: docs + */ + private function buildUrl($resourcePath, $options) { + $url = join(['/', $this->endpoint, '/']); + if (!is_null($resourcePath)){ + $url .= $resourcePath; + } + + if( !empty($options['query'])) { + $queryString = http_build_query($options['query']); + $url .= '?'.$queryString; + } + + return $url; + } + + + /** + * TODO: Docs + */ + private function buildBody($options) { + $body = null; + if( !empty($options['body']) ) { + $model = static::$structure; + $requestModel = $this->buildRequestModel( $options['body'], $model ); + $body = json_encode($requestModel); + } + return $body; + } + + /** * @desc Private Method for issuing GET and DELETE request to current API endpoint * @@ -117,35 +273,19 @@ class APIResource { * @param array $options (optional) query string parameters * @return array Result set of action performed on resource */ - private static function callResource( $action, $resourcePath=null, $options=[] ) { + private function callResource( $action, $resourcePath=null, $options=[] ) { $action = strtoupper($action); // normalize if( !in_array($action, ['POST', 'PUT', 'GET', 'DELETE'])) { throw new \Exception('Invalid resource action'); } - $url = '/' . static::$endpoint . '/'; - $body = null; - if (!is_null($resourcePath)){ - $url .= $resourcePath; - } - - // untested: - if( !empty($options['query'])) { - $queryString = http_build_query($options['query']); - $url .= '?'.$queryString; - } - - if( !empty($options['body']) ) { - $model = static::$structure; - $requestModel = self::buildRequestModel( $options['body'], $model ); - $body = json_encode($requestModel); - } + $url = $this->buildUrl($resourcePath, $options); + $body = $this->buildBody($options); //make request try { - $httpAdapter = SparkPost::getHttpAdapter(); - $response = SparkPost::getHttpAdapter()->send($url, $action, SparkPost::getHttpHeaders(), $body); + $response = $this->httpAdapter->send($url, $action, $this->getHttpHeaders(), $body); return json_decode($response->getBody()->getContents(), true); } /* @@ -157,13 +297,13 @@ class APIResource { if($statusCode === 404) { throw new \Exception("The specified resource does not exist", 404); } - throw new \Exception("Received bad response from ".ucfirst(static::$endpoint)." API: ". $statusCode ); + throw new \Exception("Received bad response from ".ucfirst($this->endpoint)." API: ". $statusCode ); } /* * Handles 5XX Errors, Configuration Errors, and a catch all for other errors */ catch (\Exception $exception) { - throw new \Exception("Unable to contact ".ucfirst(static::$endpoint)." API: ". $exception->getMessage()); + throw new \Exception("Unable to contact ".ucfirst($this->endpoint)." API: ". $exception->getMessage()); } } diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php index 5bcb815..e64ff9f 100644 --- a/lib/SparkPost/SparkPost.php +++ b/lib/SparkPost/SparkPost.php @@ -1,138 +1,20 @@ <?php namespace SparkPost; -use Ivory\HttpAdapter; -use Ivory\HttpAdapter\HttpAdapterInterface; -use Ivory\HttpAdapter\Configuration; - class SparkPost { - private static $config; - private static $httpAdapter; - - private static $defaults = array( - 'host'=>'api.sparkpost.com', - 'protocol'=>'https', - 'port'=>443, - 'strictSSL'=>true, - 'key'=>'', - 'version'=>'v1' - ); - - /** - * Enforce that this object can't be instansiated - */ - private function __construct(){} - - /** - * @desc Helper function for getting the configuration for http requests - * @return \Ivory\HttpAdapter\Configuration - */ - // TODO: Need to figure out how to set strictSSL - private static 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']; - $httpConfig->setBaseUri($baseUrl); - $httpConfig->setUserAgent('php-sparkpost/' . $composer['version']); - return $httpConfig; - } + public $transmission; /** - * @desc Convenience function for setting the httpAdapter and config in one step + * @desc sets up httpAdapter and config * - * @param Ivory\HttpAdapter $httpAdapter - an adapter for making http requests + * Sets up instances of sub libraries. + * + * @param Ivory\HttpAdapter $httpAdapter - An adapter for making http requests * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost - */ - public static function configure($httpAdapter, $settingsConfig) { - //need to set the config prior to setting up the adapter because of default settings for the adapter - self::setConfig($settingsConfig); - self::setHttpAdapter($httpAdapter); - } - - /** - * Allows the user to pass in values to override the defaults and set their API key - * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost - * @throws \Exception - */ - public static function setConfig(Array $settingsConfig) { - // Validate API key because its required - if (!isset($settingsConfig['key']) || empty(trim($settingsConfig['key']))){ - throw new \Exception('You must provide an API key'); - } - - self::$config = self::$defaults; - - // set config, overriding defaults - foreach ($settingsConfig as $configOption => $configValue) { - if(key_exists($configOption, self::$config)) { - self::$config[$configOption] = $configValue; - } - } - } - - /** - * @desc Merges passed in headers with default headers for http requests - * @return Array - headers to be set on http requests - */ - public static function getHttpHeaders(Array $headers = null) { - $defaultOptions = [ - 'Authorization' => self::getConfig()['key'], - 'Content-Type' => 'application/json', - ]; - - // Merge passed in headers with defaults - if (!is_null($headers)) { - foreach ($headers as $header => $value) { - $defaultOptions[$header] = $value; - } - } - return $defaultOptions; - } - - /** - * Retrieves the configuration that was previously setup by the user - * @throws \Exception - */ - public static function getConfig() { - if (self::$config === null) { - throw new \Exception('No configuration has been provided'); - } - return self::$config; - } - - /** - * TODO: Docs */ - public static function unsetConfig() { - self::$config = NULL; - } - - /** - * TODO: Docs - */ - public static function setHttpAdapter($httpAdapter) { - if (!$httpAdapter instanceOf HttpAdapterInterface) { - throw new \Exception('$httpAdapter paramter must be a valid Ivory\HttpAdapter'); - } - - self::$httpAdapter = $httpAdapter; - self::$httpAdapter->setConfiguration(self::getHttpConfig(self::getConfig())); + public function __construct($httpAdapter, $settingsConfig) { + $this->transmission = new Transmission($httpAdapter, $settingsConfig); } - - /** - * Retrieves the Http Adapter that was previously setup by the user - * @throws \Exception - */ - public static function getHttpAdapter() { - if (self::$httpAdapter === null) { - throw new \Exception('No Http Adapter has been provided'); - } - return self::$httpAdapter; - } } ?> diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index 82cc11d..3b3c056 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -8,13 +8,13 @@ use Guzzle\Http\Exception\ClientErrorResponseException; */ class Transmission extends APIResource { - public static $endpoint = 'transmissions'; + public $endpoint = 'transmissions'; /** * @desc Mapping for values passed into the send method to the values needed for the Transmission API * @var array */ - protected static $parameterMappings = array( + protected static $parameterMappings = [ 'campaign'=>'campaign_id', 'metadata'=>'metadata', 'substitutionData'=>'substitution_data', @@ -33,21 +33,21 @@ class Transmission extends APIResource { '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 * @var array */ - protected static $structure = array( + protected static $structure = [ 'return_path'=>"default@sparkpostmail.com", - 'content'=>array( + 'content'=>[ 'html'=>null, 'text'=>null, 'email_rfc822'=>null - ), + ], 'use_draft_template'=>false - ); + ]; /** * @desc Method for issuing POST request to the Transmissions API @@ -75,8 +75,8 @@ class Transmission extends APIResource { * * @return array API repsonse represented as key-value pairs */ - public static function send( $transmissionConfig ) { - return self::create( $transmissionConfig ); + public function send( $transmissionConfig ) { + return $this->create( $transmissionConfig ); } /** @@ -85,12 +85,12 @@ class Transmission extends APIResource { * * @return array result Set of transmissions */ - public static function all( $campaignID=null, $templateID=null ) { - $options = array(); + public function all( $campaignID=null, $templateID=null ) { + $options = []; if( $campaignID !== NULL ) $options['campaign_id'] = $campaignID; if( $templateID !== NULL ) $options['template_id'] = $templateID; - return self::get( null, $options ); + return $this->get( null, $options ); } /** @@ -100,8 +100,8 @@ class Transmission extends APIResource { * @param string $transmissionID Identifier of the transmission to be found * @return array result Single transmission represented in key-value pairs */ - public static function find($transmissionID) { - return self::get($transmissionID); + public function find($transmissionID) { + return $this->get($transmissionID); } } |