-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 477b8c8
Showing
37 changed files
with
1,084 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
Please read and understand the contribution guide before creating an issue or pull request. | ||
|
||
## Etiquette | ||
|
||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code | ||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be | ||
extremely unfair for them to suffer abuse or anger for their hard work. | ||
|
||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the | ||
world that developers are civilized and selfless people. | ||
|
||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient | ||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. | ||
|
||
## Viability | ||
|
||
When requesting or submitting new features, first consider whether it might be useful to others. Open | ||
source projects are used by many developers, who may have entirely different needs to your own. Think about | ||
whether or not your feature is likely to be used by other users of the project. | ||
|
||
## Procedure | ||
|
||
Before filing an issue: | ||
|
||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. | ||
- Check to make sure your feature suggestion isn't already present within the project. | ||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. | ||
- Check the pull requests tab to ensure that the feature isn't already in progress. | ||
|
||
Before submitting a pull request: | ||
|
||
- Check the codebase to ensure that your feature doesn't already exist. | ||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. | ||
|
||
## Requirements | ||
|
||
If the project maintainer has any additional requirements, you will find them listed here. | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
**Happy coding**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Security Policy | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) JustBetter | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# Laravel Akeneo Client | ||
|
||
Connect to your Akeneo instance using the official [akeneo/api-php-client](https://github.com/akeneo/api-php-client). | ||
This package will ease configuration, dependency injection and testing for Laravel. | ||
|
||
It also has an endpoint available to receive Akeneo events, if enabled. | ||
|
||
## Example usage | ||
|
||
```php | ||
<?php | ||
|
||
use JustBetter\AkeneoClient\Client\Akeneo; | ||
|
||
public function __construct(Akeneo $akeneo) | ||
{ | ||
$product = $akeneo->getProductApi()->get('1000'); | ||
} | ||
``` | ||
|
||
## Installation | ||
|
||
Install the composer package. | ||
|
||
```shell | ||
composer require justbetter/laravel-akeneo-client | ||
``` | ||
|
||
By default, this package will require the latest version of `akeneo/api-php-client`. You should take a look at the | ||
[compatibility table](https://github.com/akeneo/api-php-client) to see what version you need for your project. | ||
|
||
```shell | ||
composer require akeneo/api-php-client "^9.0" | ||
``` | ||
|
||
## Setup | ||
|
||
Optionally, publish the configuration of the package. | ||
|
||
```shell | ||
php artisan vendor:publish --provider="JustBetter\AkeneoClient\ServiceProvider" --tag=config | ||
``` | ||
|
||
## Configuration | ||
|
||
Add the following values to your `.env` file. | ||
|
||
``` | ||
AKENEO_URL= | ||
AKENEO_CLIENT_ID= | ||
AKENEO_SECRET= | ||
AKENEO_USERNAME= | ||
AKENEO_PASSWORD= | ||
AKENEO_EVENT_SECRET= | ||
``` | ||
|
||
## Events | ||
|
||
If you have [enabled](https://help.akeneo.com/pim/serenity/articles/manage-event-subscription.html) the event | ||
subscription in Akeneo you will be to listen to these events. | ||
|
||
The event webhook is `/akeneo/event`. This can be configured using the `prefix` in your `akeneo` config file. | ||
|
||
[All](https://api.akeneo.com/events-reference/events-reference-serenity/products.html) events are available. | ||
|
||
```php | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Event; | ||
use JustBetter\AkeneoClient\Events\ProductCreatedEvent; | ||
|
||
Event::listen(function (ProductCreatedEvent $event): void { | ||
// | ||
}); | ||
``` | ||
|
||
## Testing | ||
|
||
This package makes testing and mocking Akeneo calls very easily. | ||
|
||
```php | ||
<?php | ||
use Illuminate\Support\Facades\Http; | ||
use JustBetter\AkeneoClient\Client\Akeneo; | ||
|
||
// This will fake Akeneo credentials and a sign in. | ||
Akeneo::fake(); | ||
|
||
// Fake the specific call you will be using | ||
Http::fake([ | ||
'akeneo/api/rest/v1/products/1000' => Http::response([ | ||
'identifier' => '1000', | ||
'enabled' => true, | ||
'family' => 'hydras', | ||
'categories' => [], | ||
'groups' => [], | ||
'parent' => null, | ||
'values' => [ | ||
'name' => [ | ||
[ | ||
'locale' => 'nl_NL', | ||
'scope' => 'ecommerce', | ||
'data' => 'Ziggy', | ||
], | ||
], | ||
], | ||
]), | ||
]); | ||
|
||
// Get the product with the fake response | ||
$response = $akeneo->getProductApi()->get('1000'); | ||
``` | ||
|
||
## Quality | ||
|
||
To ensure the quality of this package, run the following command: | ||
|
||
```shell | ||
composer quality | ||
``` | ||
|
||
This will execute three tasks: | ||
|
||
1. Makes sure all tests are passed | ||
2. Checks for any issues using static code analysis | ||
3. Checks if the code is correctly formatted | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. | ||
|
||
## Security Vulnerabilities | ||
|
||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities. | ||
|
||
## Credits | ||
|
||
- [Ramon Rietdijk](https://github.com/ramonrietdijk) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "justbetter/laravel-akeneo-client", | ||
"description": "A Laravel package for the Akeneo API", | ||
"type": "package", | ||
"license": "MIT", | ||
"homepage": "https://github.com/justbetter/laravel-akeneo-client", | ||
"authors": [ | ||
{ | ||
"name": "Ramon Rietdijk", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.0", | ||
"akeneo/api-php-client": "*", | ||
"guzzlehttp/guzzle": "^7.4", | ||
"laravel/framework": "^9.0" | ||
}, | ||
"require-dev": { | ||
"laravel/pint": "^1.1", | ||
"nunomaduro/larastan": "^2.1", | ||
"orchestra/testbench": "^7.0", | ||
"phpstan/phpstan-mockery": "^1.1", | ||
"phpunit/phpunit": "^9.5.10" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"JustBetter\\AkeneoClient\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"JustBetter\\AkeneoClient\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"analyse": "phpstan", | ||
"style": "pint --test", | ||
"quality": [ | ||
"@test", | ||
"@analyse", | ||
"@style" | ||
] | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"JustBetter\\AkeneoClient\\ServiceProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'url' => env('AKENEO_URL'), | ||
|
||
'client_id' => env('AKENEO_CLIENT_ID'), | ||
|
||
'secret' => env('AKENEO_SECRET'), | ||
|
||
'username' => env('AKENEO_USERNAME'), | ||
|
||
'password' => env('AKENEO_PASSWORD'), | ||
|
||
'event_secret' => env('AKENEO_EVENT_SECRET'), | ||
|
||
'queue' => 'default', | ||
|
||
'prefix' => 'akeneo', | ||
|
||
'middleware' => [ | ||
\JustBetter\AkeneoClient\Http\Middleware\HMacMiddleware::class, | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
includes: | ||
- ./vendor/nunomaduro/larastan/extension.neon | ||
- ./vendor/phpstan/phpstan-mockery/extension.neon | ||
|
||
parameters: | ||
paths: | ||
- src | ||
- tests | ||
level: 8 | ||
checkMissingIterableValueType: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory>./tests/*</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use JustBetter\AkeneoClient\Http\Controllers\EventController; | ||
|
||
Route::post('event', [EventController::class, 'process']) | ||
->name('akeneo.event'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace JustBetter\AkeneoClient\Actions; | ||
|
||
use Illuminate\Support\Facades\Event; | ||
use JustBetter\AkeneoClient\Contracts\DispatchesEvents; | ||
use JustBetter\AkeneoClient\Contracts\ResolvesEvents; | ||
|
||
class DispatchEvent implements DispatchesEvents | ||
{ | ||
public function __construct( | ||
public ResolvesEvents $resolvesEvents | ||
) { | ||
} | ||
|
||
public function dispatch(array $event): void | ||
{ | ||
$class = $this->resolvesEvents->resolve($event['action']); | ||
|
||
Event::dispatch( | ||
app($class, [ | ||
'event' => $event, | ||
]) | ||
); | ||
} | ||
|
||
public static function bind(): void | ||
{ | ||
app()->singleton(DispatchesEvents::class, static::class); | ||
} | ||
} |
Oops, something went wrong.