summaryrefslogtreecommitdiffstats
path: root/examples/unwrapped/create_template.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/unwrapped/create_template.php')
-rw-r--r--examples/unwrapped/create_template.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/examples/unwrapped/create_template.php b/examples/unwrapped/create_template.php
index 0e24fd6..a3431d4 100644
--- a/examples/unwrapped/create_template.php
+++ b/examples/unwrapped/create_template.php
@@ -3,27 +3,32 @@ namespace Examples\Unwrapped;
require_once (dirname(__FILE__).'/../bootstrap.php');
//pull in API key config
-$configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json");
+$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';
+ // define the endpoint
+ $sparky->setupUnwrapped('templates');
- $templateConfig = array(
- '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);
- echo 'Congrats you can use your SDK!';
+ $templateConfig = [
+ 'name' => 'Summer Sale!',
+ '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();
+ echo $exception->getMessage();
}
?>