summaryrefslogtreecommitdiffstats
path: root/lib/MessageSystems/SparkPost.php
diff options
context:
space:
mode:
authornornholdj <nornholdj@gmail.com>2014-11-04 18:00:01 -0500
committernornholdj <nornholdj@gmail.com>2014-11-04 18:00:01 -0500
commitfea870e7ce1a59accdb4e2e4be2c41170523d4c7 (patch)
treeca192a9ea0084b7f59807ff5fd3c262bb05ebb6d /lib/MessageSystems/SparkPost.php
parent5d346d241fc0d0b565d7aa6ce0179a5da4c73dc0 (diff)
parent39f2699a7e7850397882a6d2ee3a8438a105b72d (diff)
downloadphp-sparkpost-fea870e7ce1a59accdb4e2e4be2c41170523d4c7.zip
php-sparkpost-fea870e7ce1a59accdb4e2e4be2c41170523d4c7.tar.gz
php-sparkpost-fea870e7ce1a59accdb4e2e4be2c41170523d4c7.tar.bz2
Merge branch 'release/1'
Diffstat (limited to 'lib/MessageSystems/SparkPost.php')
-rw-r--r--lib/MessageSystems/SparkPost.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/MessageSystems/SparkPost.php b/lib/MessageSystems/SparkPost.php
new file mode 100644
index 0000000..b1ad20a
--- /dev/null
+++ b/lib/MessageSystems/SparkPost.php
@@ -0,0 +1,51 @@
+<?php
+namespace MessageSystems;
+
+class SparkPost {
+
+ private static $config;
+ private static $defaults = [
+ 'host'=>'api.sparkpost.com',
+ 'protocol'=>'https',
+ 'port'=>443,
+ 'strictSSL'=>true,
+ 'key'=>'',
+ 'version'=>'v1'
+ ];
+
+ /**
+ * Enforce that this object can't be instansiated
+ */
+ private function __construct(){}
+
+ /**
+ * Allows the user to pass in values to override the defaults and set their API key
+ * @param Array $configMap - Hashmap that contains config values for the SDK to connect to SparkPost
+ * @throws \Exception
+ */
+ public static function setConfig(array $configMap) {
+ //check for API key because its required
+ if (!isset($configMap['key']) || empty(trim($configMap['key']))){
+ throw new \Exception('You must provide an API key');
+ }
+ self::$config = self::$defaults;
+ foreach ($configMap as $configOption => $configValue) {
+ if(key_exists($configOption, self::$config)) {
+ self::$config[$configOption] = $configValue;
+ }
+ }
+ }
+
+ /**
+ * 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;
+ }
+}
+
+?> \ No newline at end of file