Skip to content

Commit

Permalink
Add buildConfiguration() method
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Aug 2, 2019
1 parent ce8c203 commit 2222d57
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

### [1.0.2](https://github.com/webeweb/pexels-library/tree/v1.0.2) (2019-08-02)

- Add buildConfiguration()

### [1.0.1](https://github.com/webeweb/pexels-library/tree/v1.0.1) (2019-07-22)

- Add PHP extensions into Composer
Expand Down
27 changes: 18 additions & 9 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ public function __construct() {
$this->setDebug(false);
}

/**
* Build the configuration.
*
* @return array Returns the configuration.
*/
private function buildConfiguration() {
return [
"debug" => $this->getDebug(),
"headers" => [
"Accept" => "application/json",
"User-Agent" => "webeweb/pexels-library",
"Authorization" => $this->getAuthorization(),
],
"synchronous" => true,
];
}

/**
* Build a resource path.
*
Expand Down Expand Up @@ -97,15 +114,7 @@ private function callAPI($uri, array $queryData) {

try {

$client = new Client([
"debug" => $this->getDebug(),
"headers" => [
"Accept" => "application/json",
"User-Agent" => "webeweb/pexels-library",
"Authorization" => $this->getAuthorization(),
],
"synchronous" => true,
]);
$client = new Client($this->buildConfiguration());

$options = 0 < count($queryData) ? ["query" => $queryData] : [];

Expand Down

0 comments on commit 2222d57

Please sign in to comment.