diff --git a/Classes/Domain/Model/ThumbnailGenerator/FilePreviewsThumbnailGenerator.php b/Classes/Domain/Model/ThumbnailGenerator/FilePreviewsThumbnailGenerator.php index 92611bd..6e23648 100644 --- a/Classes/Domain/Model/ThumbnailGenerator/FilePreviewsThumbnailGenerator.php +++ b/Classes/Domain/Model/ThumbnailGenerator/FilePreviewsThumbnailGenerator.php @@ -1,18 +1,18 @@ null, 'width' => null ], $size); diff --git a/Classes/Service/Client.php b/Classes/Service/Client.php index 193e92b..f2e7341 100644 --- a/Classes/Service/Client.php +++ b/Classes/Service/Client.php @@ -1,22 +1,23 @@ client = new GuzzleClient($config['api_url']); + $this->client = new GuzzleClient(['base_uri' => $config['api_url']]); $this->config = $config; } @@ -64,10 +71,17 @@ public function getDefaultHeaders() */ public function get($path) { - $request = $this->client->get($path, $this->getDefaultHeaders()); - $request->setAuth($this->config['api_key'], $this->config['api_secret']); - $response = $request->send(); - return json_decode($response->getBody(true)); + $response = $this->client->request( + 'GET', + $path, + [ + 'headers' => $this->getDefaultHeaders(), + 'auth' => [$this->config['api_key'], $this->config['api_secret']] + ] + ); + + $this->logger->debug('GET ' . $path, ['response' => $response]); + return json_decode($response->getBody()); } /** @@ -77,10 +91,31 @@ public function get($path) */ public function post($path, $data) { - $request = $this->client->post($path, $this->getDefaultHeaders(), $data); - $request->setAuth($this->config['api_key'], $this->config['api_secret']); - $response = $request->send(); - return json_decode($response->getBody(true)); + $this->logger->debug( + 'Make POST Request ' . $path, + [ + 'data' => $data, + 'config' => $this->config + ] + ); + $response = $this->client->request( + 'POST', + $path, + [ + 'headers' => $this->getDefaultHeaders(), + 'auth' => [$this->config['api_key'], $this->config['api_secret']], + 'body' => $data + ] + ); + + $this->logger->debug( + 'POST ' . $path, + [ + 'data' => $data, + 'response' => $response + ] + ); + return json_decode($response->getBody()); } } diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 8821df4..7974ebc 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -1,7 +1,7 @@ Neos: Media: thumbnailGenerators: - 'Ttree\FilePreviews\Domain\Model\ThumbnailGenerator\FilePreviewsThumbnailGenerator': + 'Unikka\FilePreviews\Domain\Model\ThumbnailGenerator\FilePreviewsThumbnailGenerator': apiKey: 'api-key' apiSecret: 'api-secret' maximumWaitingTime: 30 diff --git a/README.md b/README.md index cbd2504..9184c3c 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ This package generate thumbnail and extract metadata from different type of document based on the API of [filepreviews.io]. -This package is Composer ready, [PSR-2] and [PSR-4] compliant. - How it work ? ------------- @@ -21,7 +19,7 @@ Neos: Media: thumbnailGenerator: - 'Ttree\FilePreviews\Domain\Model\ThumbnailGenerator\FilePreviewsThumbnailGenerator': + 'Unikka\FilePreviews\Domain\Model\ThumbnailGenerator\FilePreviewsThumbnailGenerator': apiKey: 'api-key' apiSecret: 'api-secret' maximumWaitingTime: 30 @@ -34,20 +32,30 @@ Neos: - ```supportedExtensions```: check the official documentation of FilePreviews [Supported Formats] and enjoy. - ```defaultOptions```: check the [API endpoint] documentation. -Acknowledgments ---------------- -Development sponsored by [ttree ltd - neos solution provider](http://ttree.ch). +## Contribution + +We'd love you to contribute to neos-slick. We try to make it as easy as possible. +We are using semantic versioning to have more time to concentrate on important stuff +instead of struggling in the dependency or release hell. + +Therefore the first rule is to follow the [eslint commit message guideline](https://github.com/conventional-changelog-archived-repos/conventional-changelog-eslint/blob/master/convention.md). +It is really easy if you always commit via `yarn commit`. Commitizen will guide you. + +All PRs will be merged into the master branch. Travis and semantic release will check the commit messages and start +building a new release when the analysis of the latest commits will trigger that. + +If you have questions just ping us on Twitter or Github. + +## About -We try our best to craft this package with a lots of love, we are open to sponsoring, support request, ... just contact us. +The package is based on the `Ttree\FilePreviews` package. We thank the [ttree team](https://ttree.ch) for +all the efforts and initial development. -License -------- +## License +The MIT License (MIT). Please see [License File](LICENSE) for more information. -The MIT License (MIT). Please see [LICENSE](LICENSE.txt) for more information. -[PSR-2]: http://www.php-fig.org/psr/psr-2/ -[PSR-4]: http://www.php-fig.org/psr/psr-4/ [filepreviews.io]: http://filepreviews.io/ [Supported Formats]: https://filepreviews.io/docs/features/ [API endpoint]: https://filepreviews.io/docs/endpoints/ diff --git a/composer.json b/composer.json index 9359d4e..166a87a 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { - "name": "ttree/filepreviews", + "name": "unikka/filepreviews", "type": "neos-package", "license": "MIT", - "description": "Neos CMS filepreviews.io integration to generate thumbnail and extract metadata", + "description": "Neos CMS integration of filepreviews.io to generate thumbnails", "require": { - "neos/flow": ">4.0", - "neos/media": ">3.0", - "guzzle/guzzle": "~3.9" + "neos/flow": "~5.3", + "neos/media": "~4.3", + "guzzlehttp/guzzle": "^7.0" }, "autoload": { "psr-4": { - "Ttree\\FilePreviews\\": "Classes" + "Unikka\\FilePreviews\\": "Classes" } } }