diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/transmission/get_all_transmissions.php | 8 | ||||
-rw-r--r-- | examples/transmission/get_transmission.php | 8 | ||||
-rw-r--r-- | examples/transmission/rfc822.php | 26 | ||||
-rw-r--r-- | examples/transmission/send_transmission_all_fields.php | 39 | ||||
-rw-r--r-- | examples/transmission/simple_send.php | 32 | ||||
-rw-r--r-- | examples/transmission/stored_recipients_inline_content.php | 12 | ||||
-rw-r--r-- | examples/transmission/stored_template_send.php | 28 | ||||
-rw-r--r-- | examples/unwrapped/create_template.php | 23 |
8 files changed, 98 insertions, 78 deletions
diff --git a/examples/transmission/get_all_transmissions.php b/examples/transmission/get_all_transmissions.php index fb62ec7..7baf4f1 100644 --- a/examples/transmission/get_all_transmissions.php +++ b/examples/transmission/get_all_transmissions.php @@ -7,12 +7,14 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-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 b4781d7..1e749b9 100644 --- a/examples/transmission/get_transmission.php +++ b/examples/transmission/get_transmission.php @@ -7,12 +7,14 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-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 8163693..b11b34f 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.php @@ -7,21 +7,23 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-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 = $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" + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php index 28edbcc..044dcc2 100644 --- a/examples/transmission/send_transmission_all_fields.php +++ b/examples/transmission/send_transmission_all_fields.php @@ -7,39 +7,42 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try{ - $results = Transmission::send(array( + $results = $sparky->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" + ] + ] + ] + ]); + 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 eafc176..6dc3719 100644 --- a/examples/transmission/simple_send.php +++ b/examples/transmission/simple_send.php @@ -7,24 +7,26 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-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 = $sparky->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(); diff --git a/examples/transmission/stored_recipients_inline_content.php b/examples/transmission/stored_recipients_inline_content.php index a2dd8aa..3e53507 100644 --- a/examples/transmission/stored_recipients_inline_content.php +++ b/examples/transmission/stored_recipients_inline_content.php @@ -7,20 +7,22 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try { - $results = Transmission::send(array( + $results = $sparky->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) { diff --git a/examples/transmission/stored_template_send.php b/examples/transmission/stored_template_send.php index 52dbb27..936d292 100644 --- a/examples/transmission/stored_template_send.php +++ b/examples/transmission/stored_template_send.php @@ -7,22 +7,24 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try { - $results = Transmission::send(array( - "from"=>"From Envelope <from@example.com>", - "recipients"=>array( - array( - "address"=>array( - "email"=>"john.doe@sample.com" - ) - ) - ), - "template"=>"my-template" - )); + $results = $sparky->transmission->send([ + "from"=>"From Envelope <from@sparkpostbox.com>", + "recipients"=>[ + [ + "address"=>[ + "email"=>"john.doe@example.com" + ] + ] + ], + "template"=>"my-first-email" + ]); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/unwrapped/create_template.php b/examples/unwrapped/create_template.php index 0e24fd6..e28f158 100644 --- a/examples/unwrapped/create_template.php +++ b/examples/unwrapped/create_template.php @@ -7,21 +7,26 @@ $configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\APIResource; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try { // define the endpoint - APIResource::$endpoint = 'templates'; + $sparky->setupUnwrapped('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'=>'jordan-test-summer-sale', + 'content'=> [ + 'from' => 'from@sparkpostbox.com', + 'subject' => 'Summer deals', + 'html' => '<b>Check out these deals!</b>' + ] + ]; + $results = $sparky->templates->create($templateConfig); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); |