Skip to content

Commit a4c95e5

Browse files
committed
Reintroduced the possibility to pass on Guzzle Configuration to the constructor (closes #9).
1 parent 779d68f commit a4c95e5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/FabianBeiner/Todoist/TodoistClient.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ class TodoistClient extends GuzzleClient
5050
*
5151
* @param string $apiToken API token to access the Todoist API.
5252
* @param string $languageCode 2-letter code that specifies the language for due_string parameters.
53+
* @param array $guzzleConf Configuration to be passed to Guzzle client.
5354
*
5455
* @throws \FabianBeiner\Todoist\TodoistException
5556
*/
56-
public function __construct(string $apiToken, string $languageCode = 'en')
57+
public function __construct(string $apiToken, string $languageCode = 'en', array $guzzleConf = [])
5758
{
5859
$apiToken = trim($apiToken);
5960
if (40 !== strlen($apiToken)) {
@@ -68,13 +69,15 @@ public function __construct(string $apiToken, string $languageCode = 'en')
6869
$defaults = [
6970
'headers' => [
7071
'Accept-Encoding' => 'gzip',
71-
'Authorization' => sprintf('Bearer %s', $apiToken),
7272
],
7373
'http_errors' => false,
7474
'timeout' => 10,
75-
'base_uri' => $this->restApiUrl,
7675
];
7776

78-
parent::__construct($defaults);
77+
$config = array_replace_recursive($defaults, $guzzleConf);
78+
$config['base_uri'] = $this->restApiUrl;
79+
$config['headers']['Authorization'] = sprintf('Bearer %s', $apiToken);
80+
81+
parent::__construct($config);
7982
}
8083
}

0 commit comments

Comments
 (0)