rossjcooper/laravel-amazon-products

A Laravel wrapper for the Amazon Products API SDK

1.0.4 2022-07-06 19:59 UTC

This package is auto-updated.

Last update: 2024-03-07 00:10:40 UTC


README

Build Status Latest Stable Version Total Downloads License

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

  1. composer require rossjcooper/laravel-amazon-products
  2. For Laravel 5.4 or earlier, in your config/app.php file:
    • Add Rossjcooper\LaravelAmazonProducts\ServiceProvider::class to your providers array in config/app.php.
    • Add 'AmazonProductsAPI' => Rossjcooper\LaravelAmazonProducts\Facades\API::class to your aliases array in config/app.php.
  3. php artisan vendor:publish --provider="Rossjcooper\LaravelAmazonProducts\ServiceProvider" --tag="config" will create a config/amazon_products.php file.
  4. Add your Amazon access and secret keys into the your .env file:
AMAZON_PRODUCTS_ACCESS_KEY=youAccessKey
AMAZON_PRODUCTS_PRIVATE_KEY=youPrivateKey
  1. 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