Skip to content

Commit

Permalink
feat: Allow to pass configuration
Browse files Browse the repository at this point in the history
Allow to pass a custom Guzzle configuration to the connection.
  • Loading branch information
LuukvH authored and StijnKing committed Jul 8, 2024
1 parent 32d08f6 commit 9ddffba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require __DIR__ . '/vendor/autoload.php';

$access_token = '<ACCESS_TOKEN>'; # testing program builder key
$access_token = '<ACCESS_TOKEN>';

$connection = new Eduframe\Connection();

Expand Down
19 changes: 17 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Connection
*/
private $client;

/**
* @var Configuration
*/
private $clientConfig;

/**
* @var array Middlewares for the Guzzle 6 client
*/
Expand All @@ -46,6 +51,14 @@ class Connection
*/
private $stage = PRODUCTION;

/**
* Eduframe constructor.
* @param \Eduframe\Connection $connection
*/
public function __construct(array $clientConfig = []) {
$this->clientConfig = $clientConfig;
}

/**
* @return Client
*/
Expand All @@ -59,13 +72,15 @@ private function client() {
$handlerStack->push($middleWare);
}

$args = [
$defaultClientConfig = [
'http_errors' => true,
'handler' => $handlerStack,
'expect' => false,
];

$this->client = new Client($args);
$clientConfig = array_merge($defaultClientConfig, $this->clientConfig);

$this->client = new Client($clientConfig);

return $this->client;
}
Expand Down

0 comments on commit 9ddffba

Please sign in to comment.