2017 © Pedro Peláez
 

library simpleapa

image

rootman/simpleapa

  • Friday, January 6, 2017
  • by rootman
  • Repository
  • 1 Watchers
  • 1 Stars
  • 106 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

SimpleAPA

A simple wrapper for https://github.com/Exeu/apai-io Amazon Product Advertising API., (*1)

Installation

Add to composer.json:, (*2)

{
    "require": {
        "rootman/simpleapa": "~1.0"
    }
}

Fire up composer:, (*3)

``` bash $ composer install, (*4)


### Laravel specific Register the Serviceprovider. Publish the config: ``` bash $ php artisan vendor:publish

Fill the config., (*5)

Usage

Framework agnostic

use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;

$conf = new GenericConfiguration();
$conf
    ->setCountry('de')
    ->setAccessKey('AMAZON ACCESS KEY')
    ->setSecretKey('AMAZON SECRET KEY')
    ->setAssociateTag('AMAZON ASSOCIATE TAG')
    ->setRequest('\ApaiIO\Request\Soap\Request')
    ->setResponseTransformer('\ApaiIO\ResponseTransformer\ObjectToArray');

$apa = SimpleAPA(new ApaiIO($conf));

$apa->bestPrice('B004BM3M6W');

Laravel

$apa = App::make(\Rootman\Simpleapa\SimpleAPA); // don't actually use it like that, better inject it

$apa->bestPrice('B004BM3M6W');

Sample helper file

<?php
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use Rootman\Simpleapa\SimpleAPA;

/**
 * @param $asin
 * @return mixed
 */
function bestPrice($asin)
{
    return Cache::remember('asin_' . $asin, 60 * 24, function () use ($asin) {
        return App::make(SimpleAPA::class)->bestPrice($asin);
    });
}

/**
 * @param $price
 * @return string
 */
function formatPrice($price)
{
    return number_format($price, 2, ',', '.');
}

/**
 * @return string
 */
function getTag()
{
    return env('ASSOCIATE_TAG');
}

/**
 * @param $asin
 * @return string
 */
function amazonUrl($asin)
{
    return sprintf('http://www.amazon.de/dp/%s/?tag=%s', $asin, getTag());
}

/**
 * @param $asin
 * @return string
 */
function amazonRatingUrl($asin)
{
    return sprintf('http://www.amazon.de/product-reviews/%s/?tag=%s', $asin, getTag());
}

The Versions

06/01 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tim Rottmann
by Yeong-Cheol Jang

06/01 2017

1.0.5

1.0.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tim Rottmann
by Yeong-Cheol Jang

01/03 2016

1.0.4

1.0.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tim Rottmann
by Yeong-Cheol Jang

08/01 2016

1.0.3

1.0.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tim Rottmann
by Yeong-Cheol Jang

25/08 2015

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tim Rottmann

25/08 2015

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

by Tim Rottmann

25/08 2015

1.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Tim Rottmann