@@ -35,7 +35,9 @@ class SparkPost {
35
35
* Sets up instances of sub libraries.
36
36
*
37
37
* @param Ivory\HttpAdapter $httpAdapter - An adapter for making http requests
38
- * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost
38
+ * @param String | Array $settingsConfig - Hashmap that contains config values
39
+ * for the SDK to connect to SparkPost. If its a string we assume that
40
+ * its just they API Key.
39
41
*/
40
42
public function __construct ($ httpAdapter , $ settingsConfig ) {
41
43
//config needs to be setup before adapter because of default adapter settings
@@ -107,10 +109,17 @@ public function setHttpAdapter($httpAdapter) {
107
109
108
110
/**
109
111
* Allows the user to pass in values to override the defaults and set their API key
110
- * @param Array $settingsConfig - Hashmap that contains config values for the SDK to connect to SparkPost
112
+ * @param String | Array $settingsConfig - Hashmap that contains config values
113
+ * for the SDK to connect to SparkPost. If its a string we assume that
114
+ * its just they API Key.
111
115
* @throws \Exception
112
116
*/
113
- public function setConfig (Array $ settingsConfig ) {
117
+ public function setConfig ($ settingsConfig ) {
118
+ // if the config map is a string we should assume that its an api key
119
+ if (is_string ($ settingsConfig )) {
120
+ $ settingsConfig = ['key ' =>$ settingsConfig ];
121
+ }
122
+
114
123
// Validate API key because its required
115
124
if (!isset ($ settingsConfig ['key ' ]) || empty (trim ($ settingsConfig ['key ' ]))){
116
125
throw new \Exception ('You must provide an API key ' );
0 commit comments