Skip to content

Commit

Permalink
Merge pull request #1328 from dasgarner/develop
Browse files Browse the repository at this point in the history
Prepare for 3.1.0-beta release. Update swagger.
  • Loading branch information
dasgarner authored Feb 8, 2022
2 parents 13ac3d5 + db41100 commit 6f53890
Show file tree
Hide file tree
Showing 4 changed files with 453 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/Connector/ConnectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public function useHttpOptions($options): ConnectorInterface
return $this;
}

/**
* Get an HTTP client with the default proxy settings, etc
* @return \GuzzleHttp\Client
*/
public function getClient(): Client
{
return new Client($this->httpOptions);
Expand Down
11 changes: 7 additions & 4 deletions lib/Connector/PixabayConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Xibo\Connector;

use Carbon\Carbon;
use GuzzleHttp\Client;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Xibo\Entity\SearchResult;
use Xibo\Event\LibraryProviderEvent;
Expand Down Expand Up @@ -84,6 +83,12 @@ public function onLibraryProvider(LibraryProviderEvent $event)
{
$this->getLogger()->debug('onLibraryProvider');

// Do we have an alternative URL (we may proxy requests for cache)
$baseUrl = $this->getSetting('baseUrl');
if (empty($baseUrl)) {
$baseUrl = 'https://pixabay.com/api/';
}

// Do we have an API key?
$apiKey = $this->getSetting('apiKey');
if (empty($apiKey)) {
Expand Down Expand Up @@ -138,9 +143,7 @@ public function onLibraryProvider(LibraryProviderEvent $event)
$this->getLogger()->debug('onLibraryProvider: cache miss, generating.');

// Make the request
$client = new Client();
$uri = $type === 'video' ? 'https://pixabay.com/api/videos' : 'https://pixabay.com/api/';
$request = $client->request('GET', $uri, [
$request = $this->getClient()->request('GET', $baseUrl . ($type === 'video' ? 'videos' : ''), [
'query' => $query
]);

Expand Down
3 changes: 1 addition & 2 deletions lib/Connector/XiboExchangeConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public function onTemplateProvider(TemplateProviderEvent $event)
$this->getLogger()->debug('onTemplateProvider: cache miss, generating.');

// Make the request
$client = new Client();
$request = $client->request('GET', $uri);
$request = $this->getClient()->request('GET', $uri);

$body = $request->getBody()->getContents();
if (empty($body)) {
Expand Down
Loading

0 comments on commit 6f53890

Please sign in to comment.