Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow to pass custom configuration #119

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading