rossjcooper / laravel-amazon-products
A Laravel wrapper for the Amazon Products API SDK
1.0.4
2022-07-06 19:59 UTC
Requires
- illuminate/support: >=5.3
- rossjcooper/paapiphpsdk: ^1.0|^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- orchestra/testbench: >=3.4
README
This is a wrapper for the rossjcooper/paapiphpsdk package and gives the user a Service Container binding and facade a configured instance of the Amazon\ProductAdvertisingAPI\v1\com\amazon\paapi5\v1\api\DefaultApi
class.
Installation
composer require rossjcooper/laravel-amazon-products
- For Laravel 5.4 or earlier, in your
config/app.php
file:- Add
Rossjcooper\LaravelAmazonProducts\ServiceProvider::class
to your providers array inconfig/app.php
. - Add
'AmazonProductsAPI' => Rossjcooper\LaravelAmazonProducts\Facades\API::class
to your aliases array inconfig/app.php
.
- Add
php artisan vendor:publish --provider="Rossjcooper\LaravelAmazonProducts\ServiceProvider" --tag="config"
will create aconfig/amazon_products.php
file.- Add your Amazon access and secret keys into the your
.env
file:
AMAZON_PRODUCTS_ACCESS_KEY=youAccessKey
AMAZON_PRODUCTS_PRIVATE_KEY=youPrivateKey
- Optionally update your host and region values in the
config/amazon_products.php
file.
Usage
public function handle(\Rossjcooper\LaravelAmazonProducts\API $api) { $request = new SearchItemsRequest(); $request->setSearchIndex('All'); $request->setKeywords('Harry Potter'); $request->setResources([ SearchItemsResource::ITEM_INFOTITLE, SearchItemsResource::OFFERSLISTINGSPRICE, ]); $request->setPartnerTag(config('mypartnertag')); $request->setPartnerType(config('Associates')); $response = $api->searchItems($request); foreach($response->getSearchResult()->getItems() as $item) { //... } }
For more info on using the actual SDK see the main repo rossjcooper/paapiphpsdk
Testing
We're using the brilliant Orchestra Testbench v4 to run unit tests in a Laravel based environment.
Issues
Please only report issues relating to the Laravel side of things here, main API issues should be reported here