diff options
author | beardyman <nornholdj@gmail.com> | 2015-09-16 23:25:03 -0400 |
---|---|---|
committer | beardyman <nornholdj@gmail.com> | 2015-09-16 23:25:03 -0400 |
commit | b51ce2d0a8fad2577c164e1ab1c8382b1ae23fae (patch) | |
tree | 0cfd23aff75b957b0beb7e88e4c0a544c5c107b5 /examples | |
parent | 0c4b276fd3c51e938474071fcde5b294a7651256 (diff) | |
download | php-sparkpost-b51ce2d0a8fad2577c164e1ab1c8382b1ae23fae.zip php-sparkpost-b51ce2d0a8fad2577c164e1ab1c8382b1ae23fae.tar.gz php-sparkpost-b51ce2d0a8fad2577c164e1ab1c8382b1ae23fae.tar.bz2 |
finished code updates/refactoring updated examples and began refactoring tests
Diffstat (limited to 'examples')
-rw-r--r-- | examples/transmission/get_all_transmissions.php | 5 | ||||
-rw-r--r-- | examples/transmission/get_transmission.php | 12 | ||||
-rw-r--r-- | examples/transmission/rfc822.php | 29 | ||||
-rw-r--r-- | examples/transmission/send_transmission_all_fields.php | 45 | ||||
-rw-r--r-- | examples/transmission/simple_send.php | 37 | ||||
-rw-r--r-- | examples/transmission/stored_recipients_inline_content.php | 15 | ||||
-rw-r--r-- | examples/transmission/stored_template_send.php | 29 | ||||
-rw-r--r-- | examples/unwrapped/create_template.php | 27 |
8 files changed, 114 insertions, 85 deletions
diff --git a/examples/transmission/get_all_transmissions.php b/examples/transmission/get_all_transmissions.php index 54cb376..1e1882b 100644 --- a/examples/transmission/get_all_transmissions.php +++ b/examples/transmission/get_all_transmissions.php @@ -7,13 +7,12 @@ use SparkPost\Transmission; use GuzzleHttp\Client; use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; +$key = 'YOUR API KEY'; $httpAdapter = new Guzzle6HttpAdapter(new Client()); -SparkPost::setConfig($httpAdapter, ['key'=>$key]); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { $results = Transmission::all(); - var_dump($results); 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 574388c..84cd227 100644 --- a/examples/transmission/get_transmission.php +++ b/examples/transmission/get_transmission.php @@ -3,14 +3,18 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; + +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); try { - $results = Transmission::find('Your Transmission Id'); + $results = Transmission::find('Your Transmission ID'); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/transmission/rfc822.php b/examples/transmission/rfc822.php index b97bbb9..ec932e7 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.php @@ -3,23 +3,26 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send(array( - 'recipients'=>array( - array( - 'address'=>array( - 'email'=>'john.doe@sample.com' - ) - ) - ), - 'rfc822'=>"Content-Type: text/plain\nFrom: From Envelope <from@example.com>\nSubject: Example Email\n\nHello World" - )); + $results = 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" + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php index 30f7793..3bd9315 100644 --- a/examples/transmission/send_transmission_all_fields.php +++ b/examples/transmission/send_transmission_all_fields.php @@ -3,41 +3,48 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); + +// TODO: update all from emails to = sandbox domain try{ - $results = Transmission::send(array( + $results = Transmission::send([ "campaign"=>"my-campaign", - "metadata"=>array( + "metadata"=>[ "sample_campaign"=>true, "type"=>"these are custom fields" - ), - "substitutionData"=>array( + ], + "substitutionData"=>[ "name"=>"Test Name" - ), + ], "description"=>"my description", "replyTo"=>"reply@test.com", - "customHeaders"=>array( + "customHeaders"=>[ "X-Custom-Header"=>"Sample Custom Header" - ), + ], "trackOpens"=>false, "trackClicks"=>false, - "from"=>"From Envelope <from@example.com>", + "from"=>"From Envelope <from@sparkpostbox.com>", "html"=>"<p>Hello World! Your name is: {{name}}</p>", "text"=>"Hello World!", "subject"=>"Example Email: {{name}}", - "recipients"=>array( - array( - "address"=>array( - "email"=>"john.doe@sample.com" - ) - ) - ) - )); + "recipients"=>[ + [ + "address"=>[ + "email"=>"john.doe@example.com" + ] + ] + ] + ]); + + var_dump($results); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/transmission/simple_send.php b/examples/transmission/simple_send.php index 8149238..caaf962 100644 --- a/examples/transmission/simple_send.php +++ b/examples/transmission/simple_send.php @@ -1,29 +1,32 @@ <?php -namespace Examples\Transmisson; +namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send(array( - "from"=>"From Envelope <from@example.com>", - "html"=>"<p>Hello World!</p>", - "text"=>"Hello World!", - "subject"=>"Example Email", - "recipients"=>array( - array( - "address"=>array( - "email"=>"john.doe@example.com" - ) - ) - ) - )); + $results = Transmission::send([ + "from"=>"From Envelope <from@sparkpostbox.com>", + "html"=>"<p>Hello World!</p>", + "text"=>"Hello World!", + "subject"=>"Example Email", + "recipients"=>[ + [ + "address"=>[ + "email"=>"john.doe@example.com" + ] + ] + ] + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/transmission/stored_recipients_inline_content.php b/examples/transmission/stored_recipients_inline_content.php index dbb7c1d..42e40df 100644 --- a/examples/transmission/stored_recipients_inline_content.php +++ b/examples/transmission/stored_recipients_inline_content.php @@ -3,23 +3,26 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send(array( + $results = Transmission::send([ "campaign"=>"my-campaign", - "from"=>"From Envelope <from@example.com>", + "from"=>"From Envelope <from@sparkpostbox.com>", "html"=>"<p>Hello World! Your name is: {{name}}</p>", "text"=>"Hello World!", "subject"=>"Example Email: {{name}}", "recipientList"=>'Example List' - )); + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/transmission/stored_template_send.php b/examples/transmission/stored_template_send.php index cda6de6..82be209 100644 --- a/examples/transmission/stored_template_send.php +++ b/examples/transmission/stored_template_send.php @@ -3,24 +3,27 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { - $results = Transmission::send(array( - "from"=>"From Envelope <from@example.com>", - "recipients"=>array( - array( - "address"=>array( - "email"=>"john.doe@sample.com" - ) - ) - ), + $results = Transmission::send([ + "from"=>"From Envelope <from@sparkpostbox.com>", + "recipients"=>[ + [ + "address"=>[ + "email"=>"john.doe@example.com" + ] + ] + ], "template"=>"my-template" - )); + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> diff --git a/examples/unwrapped/create_template.php b/examples/unwrapped/create_template.php index 717430f..ee4ff6c 100644 --- a/examples/unwrapped/create_template.php +++ b/examples/unwrapped/create_template.php @@ -3,23 +3,30 @@ namespace Examples\Unwrapped; require_once (dirname(__FILE__).'/../bootstrap.php'); use SparkPost\SparkPost; use SparkPost\APIResource; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -$key = 'YOURAPIKEY'; -SparkPost::setConfig(array('key'=>$key)); +$key = 'YOUR API KEY'; +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +SparkPost::configure($httpAdapter, ['key'=>$key]); try { // define the endpoint APIResource::$endpoint = 'templates'; - - $templateConfig = array( + + $templateConfig = [ 'name' => 'Summer Sale!', - 'content.from' => 'marketing@bounces.company.example', - 'content.subject' => 'Summer deals', - 'content.html' => '<b>Check out these deals!</b>', - ); - $results = APIResource::sendRequest($templateConfig); + 'id'=>'summer-sale', + 'content'=> [ + 'from' => 'john.doe@sparkpostbox.com', + 'subject' => 'Summer deals', + 'html' => '<b>Check out these deals!</b>' + ] + ]; + $results = APIResource::create($templateConfig); + var_dump($results); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); } -?>
\ No newline at end of file +?> |