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 968e135 commit 642c0b0
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/pixabay-library/tree/v1.0.2) (2019-08-02)

- Add buildConfiguration()

### [1.0.1](https://github.com/webeweb/pixabay-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 @@ -57,6 +57,23 @@ public function __construct() {
$this->setDebug(false);
}

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

/**
* Call the API.
*
Expand All @@ -74,15 +91,7 @@ protected function callAPI(AbstractRequest $request, array $queryData) {

try {

$client = new Client([
"base_uri" => self::ENDPOINT_PATH . "/",
"debug" => $this->getDebug(),
"headers" => [
"Accept" => "application/json",
"User-Agent" => "webeweb/pixabay-library",
],
"synchronous" => true,
]);
$client = new Client($this->buildConfiguration());

$uri = substr($request->getResourcePath(), 1);
$options = [
Expand Down

0 comments on commit 642c0b0

Please sign in to comment.