summaryrefslogtreecommitdiffstats
path: root/examples/templates/get_all_templates.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/templates/get_all_templates.php')
-rw-r--r--examples/templates/get_all_templates.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/templates/get_all_templates.php b/examples/templates/get_all_templates.php
new file mode 100644
index 0000000..25e222c
--- /dev/null
+++ b/examples/templates/get_all_templates.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Examples\Templates;
+
+require dirname(__FILE__).'/../bootstrap.php';
+
+use SparkPost\SparkPost;
+use GuzzleHttp\Client;
+use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
+
+$httpClient = new GuzzleAdapter(new Client());
+
+/*
+ * configure options in example-options.json
+ */
+$sparky = new SparkPost($httpClient, $options);
+
+$promise = $sparky->request('GET', 'templates');
+
+try {
+ $response = $promise->wait();
+ echo $response->getStatusCode()."\n";
+ print_r($response->getBody())."\n";
+} catch (\Exception $e) {
+ echo $e->getCode()."\n";
+ echo $e->getMessage()."\n";
+}