summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbeardyman <nornholdj@gmail.com>2015-10-10 11:02:39 -0400
committerbeardyman <nornholdj@gmail.com>2015-10-10 11:02:39 -0400
commit0be23bb4dd085692df0942dcf0961fbd1857bd60 (patch)
tree9a9eaf187fe43e2925cc3cb6257b02295597031f /lib
parent20301cd311307b8357459a299c3c9746ecf8c065 (diff)
downloadphp-sparkpost-0be23bb4dd085692df0942dcf0961fbd1857bd60.zip
php-sparkpost-0be23bb4dd085692df0942dcf0961fbd1857bd60.tar.gz
php-sparkpost-0be23bb4dd085692df0942dcf0961fbd1857bd60.tar.bz2
Added ability to pass in api key as a config
Diffstat (limited to 'lib')
-rw-r--r--lib/SparkPost/SparkPost.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php
index d4449b8..2a554dd 100644
--- a/lib/SparkPost/SparkPost.php
+++ b/lib/SparkPost/SparkPost.php
@@ -40,11 +40,6 @@ class SparkPost {
* its just they API Key.
*/
public function __construct($httpAdapter, $settingsConfig) {
- // if the config map is a string we should assume that its an api key
- if (gettype($settingsConfig) === 'string') {
- $settingsConfig = ['key'=>$settingsConfig];
- }
-
//config needs to be setup before adapter because of default adapter settings
$this->setConfig($settingsConfig);
$this->setHttpAdapter($httpAdapter);
@@ -114,10 +109,17 @@ class SparkPost {
/**
* Allows the user to pass in values to override the defaults and set their API key
- * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost
+ * @param String | Array $settingsConfig - Hashmap that contains config values
+ * for the SDK to connect to SparkPost. If its a string we assume that
+ * its just they API Key.
* @throws \Exception
*/
- public function setConfig(Array $settingsConfig) {
+ public function setConfig($settingsConfig) {
+ // if the config map is a string we should assume that its an api key
+ if (gettype($settingsConfig) === 'string') {
+ $settingsConfig = ['key'=>$settingsConfig];
+ }
+
// Validate API key because its required
if (!isset($settingsConfig['key']) || empty(trim($settingsConfig['key']))){
throw new \Exception('You must provide an API key');