Skip to content

Commit

Permalink
Fix offloading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
selul committed Aug 6, 2024
1 parent 5d65802 commit b0749c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The second argument of the `init` method is optional. It allows you to pass opti
* `base_domain`: The base domain to connect to Optimole's API. Default is `i.optimole.com`.
* `cache_buster`: A string value that will be appended to the URL of the optimized assets to bust Optimole's cache.
* `dashboard_api_url`: The URL of the dashboard API. Default is `https://dashboard.optimole.com/api`.
* `dashboard_api_key`: The API key to use for the dashboard API.
* `upload_api_credentials`: An array with the credentials to use for the upload API. The array should contain the keys `userKey` and `secret`. The default is empty and the SDK will use the API key provided in the `init` method to fetch them from the dashboard API.
* `upload_api_url`: The URL of the upload API. Default is `https://generateurls-prod.i.optimole.com/upload`.

Expand Down
7 changes: 1 addition & 6 deletions src/Offload/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class Manager
*/
private ClientInterface $httpClient;

/**
* The Optimole API key.
*/
private string $key;

/**
* The manager options.
Expand All @@ -44,7 +40,7 @@ class Manager
/**
* Constructor.
*/
public function __construct(ClientInterface $httpClient, string $key, array $options = [])
public function __construct(ClientInterface $httpClient, array $options = [])
{
if (empty($options['dashboard_api_url'])) {
throw new InvalidArgumentException('Missing "dashboard_api_url" option');
Expand All @@ -53,7 +49,6 @@ public function __construct(ClientInterface $httpClient, string $key, array $opt
}

$this->httpClient = $httpClient;
$this->key = $key;
$this->options = array_merge([
'upload_api_credentials' => [],
], $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Optimole.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function createImage(string $imageUrl, string $cacheBuster = ''): Image
*/
private function createOffload(array $options = []): Manager
{
return new Manager($this->getHttpClient(), $this->key, array_merge($this->options, $options));
return new Manager($this->getHttpClient(), array_merge($this->options, $options));
}

/**
Expand Down
Loading

0 comments on commit b0749c8

Please sign in to comment.