Author: Jan Eichhorn (exeu65@googlemail.com)
Inheritance: implements ApaiIO\Configuration\ConfigurationInterface
 public function testCustomConfigurationPassed()
 {
     $configuration = new GenericConfiguration();
     $configuration->setCountry('de')->setAccessKey('ABC')->setSecretKey('DEF')->setAssociateTag('apaiIOTest')->setRequest(new Request());
     $request = RequestFactory::createRequest($configuration);
     $this->assertSame($configuration, \PHPUnit_Framework_Assert::readAttribute($request, 'configuration'));
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('SimpleAPA', function () {
         $conf = new GenericConfiguration();
         $conf->setCountry('de')->setAccessKey(Config::get('simpleapa.AccessKey'))->setSecretKey(Config::get('simpleapa.SecretKey'))->setAssociateTag(Config::get('simpleapa.AssociateTag'))->setRequest('\\ApaiIO\\Request\\Soap\\Request')->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\ObjectToArray');
         return new SimpleAPA(new ApaiIO($conf));
     });
 }
 protected function setUp()
 {
     if (isset($this->conf) && isset($this->apaiIO)) {
         return $this;
     }
     $this->conf = new GenericConfiguration();
     $this->conf->setCountry($this->amazonConf['country'])->setAccessKey($this->amazonConf['amazon_ws_api_key'])->setSecretKey($this->amazonConf['amazon_ws_api_secret_key'])->setAssociateTag($this->amazonConf['amazon_ws_api_associate_tag']);
     $this->apaiIO = new ApaiIO($this->conf);
     return $this;
 }
 public function connect(PaaConfigInterface $config)
 {
     $conf = new GenericConfiguration();
     try {
         $conf->setCountry($config->getCountry())->setAccessKey($config->getAccessKey())->setSecretKey($config->getSecretKey())->setAssociateTag($config->getAssociateTag());
     } catch (\Exception $e) {
         echo $e->getMessage();
         die;
     }
     $this->service = new ApaiIO($conf);
 }
Example #5
0
 public function testApaiIOTransformResponse()
 {
     $conf = new GenericConfiguration();
     $operation = new Search();
     $request = $this->getMock('\\ApaiIO\\Request\\Rest\\Request', array('perform'));
     $request->expects($this->once())->method('perform')->will($this->returnValue(array('a' => 'b')));
     $conf->setRequest($request);
     $responseTransformer = $this->getMock('\\ApaiIO\\ResponseTransformer\\ObjectToArray', array('transform'));
     $responseTransformer->expects($this->once())->method('transform')->with($this->equalTo(array('a' => 'b')));
     $conf->setResponseTransformer($responseTransformer);
     $apaiIO = new ApaiIO();
     $apaiIO->runOperation($operation, $conf);
 }
 /**
  * Builds a new ApaiIO instance
  *
  * @param array $config The configuration
  *
  * @return \ApaiIO\ApaiIO
  */
 public static function get($config)
 {
     $configuration = new GenericConfiguration();
     $configuration->setAccessKey($config['accesskey'])->setSecretKey($config['secretkey'])->setAssociateTag($config['associatetag'])->setCountry($config['country']);
     // Setting the default request-type if it has been setted up
     if (true === isset($config['request'])) {
         $configuration->setRequest($config['request']);
     }
     // Setting the default responsetransformer if it has been setted up
     if (true === isset($config['response'])) {
         $configuration->setResponseTransformer($config['response']);
     }
     return new ApaiIO($configuration);
 }
Example #7
0
 public function testamazon()
 {
     $conf = new GenericConfiguration();
     $conf->setCountry('com')->setAccessKey('AKIAIUHJDBWAEKOQI2KQ')->setSecretKey('NbqRx2HzGrhBY1eEMoamyMHAJtZck5EMAYH4jHod')->setAssociateTag('IDTAG')->setRequest('\\ApaiIO\\Request\\Soap\\Request')->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\ObjectToArray');
     $search = new Search();
     $search->setCategory('All');
     $search->setKeywords('Iphone 6s');
     $search->setResponsegroup(array('Offers', 'Images'));
     $apaiIo = new ApaiIO($conf);
     $response = $apaiIo->runOperation($search);
     //return $response["Items"]["Item"][0]["ItemAttributes"]["Title"];
     return $response;
     //test
 }
function GetProductInfoByTitle($title)
{
    $conf = new GenericConfiguration();
    try {
        $conf->setCountry('com')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG);
    } catch (\Exception $e) {
        echo $e->getMessage();
    }
    $apaiIO = new ApaiIO($conf);
    $search = new Search();
    // $lookup->setItemId('B0040PBK32,B00MEKHLLA');
    $search->setCategory('Books');
    $search->setKeywords($title);
    $formattedResponse = $apaiIO->runOperation($search);
    $dom = new DOMDocument();
    $dom->loadXML($formattedResponse);
    $arrResponse = xml_to_array($dom);
    return $arrResponse;
}
Example #9
0
 /**
  * @expectedException LogicException
  */
 public function testInvalidRequestFactoryCallbackReturnValue()
 {
     $conf = new GenericConfiguration();
     $conf->setRequestFactory(function ($request) {
         return new \stdClass();
     });
     RequestFactory::createRequest($conf);
 }
Example #10
0
<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once 'Config.php';
use ApaiIO\Request\RequestFactory;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Search;
use ApaiIO\ResponseTransformer\ObjectToArray;
use ApaiIO\Operations\Lookup;
use ApaiIO\Operations\SimilarityLookup;
use ApaiIO\Operations\CartCreate;
use ApaiIO\ApaiIO;
use ApaiIO\Operations\BrowseNodeLookup;
use ApaiIO\Operations\CartAdd;
$conf = new GenericConfiguration();
try {
    $conf->setCountry('de')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$search = new Search();
$search->setCategory('DVD');
$search->setActor('Bruce Willis');
$search->setKeywords('Stirb Langsam');
$search->setPage(3);
$search->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($search);
echo $formattedResponse;
exit;
// var_dump($formattedResponse);
Example #11
0
 public function testCountrySetter()
 {
     $object = new GenericConfiguration();
     $object->setCountry('DE');
     $this->assertEquals('de', $object->getCountry());
 }
Example #12
0
 /**
  * @expectedException LogicException
  */
 public function testInvalidRequestFactoryCallbackReturnValue()
 {
     $conf = new GenericConfiguration();
     $conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\XmlToDomDocument');
     $conf->setResponseTransformerFactory(function ($response) {
         return new \stdClass();
     });
     ResponseTransformerFactory::createResponseTransformer($conf);
 }
Example #13
0
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Config.php';
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Lookup;
$conf = new GenericConfiguration();
try {
    $conf->setCountry('de')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$lookup = new Lookup();
$lookup->setItemId('B0040PBK32,B00MEKHLLA');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
echo $formattedResponse;
// Change the ResponseTransformer to DOMDocument.
$conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\XmlToDomDocument');
$formattedResponse = $apaiIO->runOperation($lookup);
var_dump($formattedResponse);
Example #14
0
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Config.php';
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\CartAdd;
use ApaiIO\Operations\CartCreate;
$conf = new GenericConfiguration();
try {
    $conf->setCountry('de')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$cartCreate = new CartCreate();
$cartCreate->addItem("B0040PBK32", 1);
$formattedResponse = $apaiIO->runOperation($cartCreate);
echo $formattedResponse;
echo "<hr>";
$cartAdd = new CartAdd();
$cartAdd->setCartId('280-6695255-7497359');
$cartAdd->setHMAC('LxQ0BKVBeQTrzFCXvIoa/262EcU=');
$cartAdd->addItem('B003YL444A', 1);
 /**
  * @Route(
  *    path = "/search/searchByText/{text}",
  *    name = "searchByText",
  *    defaults={"text" = "012345678901"}
  * )
  */
 public function searchByTextAction(Request $request)
 {
     /* TODO: DISPLAYING A MESSAGE WHEN NOTHING HAS BEEN FOUND */
     /* DISPLAYING THE INPUT FORM */
     $textQuery = array('text' => '');
     $form = $this->createFormBuilder($textQuery)->setAction($this->generateUrl('searchByText'))->setMethod('GET')->add('text', TextType::class, array('label' => 'Keywords', 'attr' => array('class' => 'form-control')))->add('submit', SubmitType::class, array('label' => 'Look for possible equivalent items', 'attr' => array('class' => 'btn btn-default')))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         // Form has been submitted or some text has been passed in the URL
         $data = $form->getData();
         if ($data['text'] != '') {
             $text = $data['text'];
         }
         // ... perform some action, such as saving the task to the database
         //$resString = print_r($data);
         //return(new Response($resString));
         /*
         searching by text,
         if found displaying what has been found
         */
         // TODO:
         // moving configuration data outside in a configuration file
         $conf = new GenericConfiguration();
         $conf->setCountry('com')->setAccessKey('AKIAJD57F37W2KGLXEVQ')->setSecretKey('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')->setAssociateTag('quercusroburn-20')->setRequest('\\ApaiIO\\Request\\Soap\\Request');
         $query = new Search();
         $query->setKeywords($text);
         $query->setCategory('Music');
         $query->setResponseGroup(array('ItemAttributes', 'Images', 'Tracks'));
         // More detailed information
         $apaiIo = new ApaiIO($conf);
         $response = $apaiIo->runOperation($query);
         $logger = $this->get('logger');
         $records = array();
         if (property_exists($response, 'Items')) {
             // handlig the case when one item only is returned,
             // in that case $response->Items->Item is not an array!!!
             $results = array();
             if (is_array($response->Items->Item)) {
                 $results = $response->Items->Item;
             } else {
                 $results[] = $response->Items->Item;
             }
             foreach ($results as $item) {
                 $logger->info('----------------------------');
                 $record = new Record();
                 // ASIN
                 $logger->info("ASIN: {$item->ASIN}");
                 $record->setAsin($item->ASIN);
                 // TODO:
                 // now getting UPC just for testing purposes,
                 // this should be stopped...
                 if (property_exists($item->ItemAttributes, 'UPC')) {
                     $logger->info('UPC: ' . $item->ItemAttributes->UPC);
                 } else {
                     $logger->info('NO UPC!');
                 }
                 // Artist
                 // Structure changes if several artists are listed
                 if (property_exists($item->ItemAttributes, 'Artist')) {
                     if (!is_array($item->ItemAttributes->Artist)) {
                         $record->setArtist($item->ItemAttributes->Artist);
                     } else {
                         $logger->info('Here it is the array: ' . print_r($item->ItemAttributes->Artist, true) . ' - Seen as: ' . gettype($item->ItemAttributes->Artist) . ' - size: ' . sizeof($item->ItemAttributes->Artist));
                         $artist = 'Various artists (';
                         for ($i = 1; $i < sizeof($item->ItemAttributes->Artist); $i++) {
                             $artist .= $item->ItemAttributes->Artist[$i];
                             if ($i < sizeof($item->ItemAttributes->Artist) - 1) {
                                 $artist .= ', ';
                             }
                         }
                         $artist .= ')';
                         $record->setArtist($artist);
                         $logger->info('Values: ' . join(' - ', $item->ItemAttributes->Artist));
                     }
                     $logger->info('Artist: ' . $record->getArtist());
                 }
                 // title
                 $record->setTitle($item->ItemAttributes->Title);
                 $logger->info('Title: ' . $record->getTitle());
                 // label
                 if (property_exists($item->ItemAttributes, 'Brand')) {
                     $record->setRecordLabel($item->ItemAttributes->Brand);
                 } else {
                     if (property_exists($item->ItemAttributes, 'Label')) {
                         $record->setRecordLabel($item->ItemAttributes->Label);
                     } else {
                         //
                     }
                 }
                 $logger->info('Label: ' . $record->getRecordLabel());
                 // Year
                 if (property_exists($item->ItemAttributes, 'ReleaseDate')) {
                     $record->setYear(substr($item->ItemAttributes->ReleaseDate, 0, 4));
                     $logger->info('Label: ' . $record->getYear());
                 } else {
                     $logger->info('\'ReleaseDate\' not available, so dunno how to get the year...');
                 }
                 // Media count
                 if (property_exists($item->ItemAttributes, 'NumberOfItems')) {
                     $record->setMediaCount($item->ItemAttributes->NumberOfItems);
                     $logger->info('Media count: ' . $record->getMediaCount());
                 } else {
                     if (property_exists($item->ItemAttributes, 'NumberOfDiscs')) {
                         $record->setMediaCount($item->ItemAttributes->NumberOfDiscs);
                         $logger->info('Media count: ' . $record->getMediaCount());
                     } else {
                         //$logger->info(print_r($item->ItemAttributes, true));
                         $logger->info('Number of media not available. Now what?! Tentatively I guess the value \'1\'.');
                         $record->setMediaCount('1');
                         $item->ItemAttributes->NumberOfItems = '1';
                     }
                 }
                 // Media type
                 $record->setMediaType($item->ItemAttributes->Binding);
                 $logger->info('Media type: ' . $record->getMediaType());
                 // Cover image (it may be unavailable)
                 if (property_exists($item, 'LargeImage')) {
                     $record->setCoverImageUrl($item->LargeImage->URL);
                     $logger->info('Cover image URL: ' . $record->getCoverImageUrl());
                 }
                 // each media item has a track list
                 $trackLists = array();
                 if (property_exists($item, 'Tracks')) {
                     // Tracks info is not for granted...
                     // When number of media/items is greater than 1, but
                     // the tracks list is just one
                     // (it happened at least once with B000B66OVW, see EX03 below)
                     // then ->Tracks->Disc is not an array at it should be
                     // when more than one media are actually present
                     $oneListOnly = 0;
                     if (!is_array($item->Tracks->Disc)) {
                         $logger->info('The web service reported ' . $record->getMediaCount() . ' media, but all tracks are in just one list.');
                         $oneListOnly = 1;
                     }
                     if ($record->getMediaCount() < 2 || $oneListOnly) {
                         // one item only, one list
                         if (property_exists($item->Tracks, 'Disc')) {
                             $totalTracks = sizeof($item->Tracks->Disc->Track);
                             for ($i = 0; $i < $totalTracks; $i++) {
                                 $tracksLists[0][] = $item->Tracks->Disc->Track[$i]->_;
                             }
                         } else {
                             $logger->info('Couldn\'t find "Disc"...   ' . print_r($item->Tracks, true));
                         }
                     } else {
                         for ($j = 0; $j < $record->getMediaCount(); $j++) {
                             $totalTracks = sizeof($item->Tracks->Disc[$j]->Track);
                             for ($i = 0; $i < $totalTracks; $i++) {
                                 $tracksLists[$j][] = $item->Tracks->Disc[$j]->Track[$i]->_;
                             }
                         }
                     }
                     $record->setTracksLists($tracksLists);
                 } else {
                     // Tracks info is not available (no property "Tracks" in the object)
                     $logger->info('Tracks info is not available');
                 }
                 // Appending the record to the list of possible records
                 $records[] = $record;
             }
         }
         // TODO:
         // saving the array of results in session
         $session = new Session();
         //$session->start();
         $session->set('results', $records);
         $logger->info('Session ID: ' . $session->getId());
         // Returning the list of the results
         // TODO:
         // handling in the template the id of each record, so that in can be passed
         // afterwards for insertion and recovered from session without re-fetching
         // its data
         return $this->render('AppBundle:Record:results.html.twig', array('records' => $records));
     }
     // The form has not been submitted, displaying the form
     return $this->render('AppBundle:Record:searchByText.html.twig', array('form' => $form->createView()));
 }
Example #16
0
});
$app->get('/amazon/node/:browsenode', function ($browsenode) {
    $conf = new GenericConfiguration();
    $conf->setCountry('com')->setAccessKey(getenv('AMAZON_ACCESS'))->setSecretKey(getenv('AMAZON_SECRET'))->setAssociateTag(getenv('AMAZON_ASSOCIATE_TAG'));
    $browseNodeLookup = new BrowseNodeLookup();
    $browseNodeLookup->setNodeId($browsenode);
    $apaiIo = new ApaiIO($conf);
    $response = $apaiIo->runOperation($browseNodeLookup);
    echo json_encode(simplexml_load_string($response));
});
$app->get('/amazon/lookup/:asin', function ($asin) {
    $conf = new GenericConfiguration();
    $conf->setCountry('com')->setAccessKey(getenv('AMAZON_ACCESS'))->setSecretKey(getenv('AMAZON_SECRET'))->setAssociateTag(getenv('AMAZON_ASSOCIATE_TAG'));
    $apaiIo = new ApaiIO($conf);
    $lookup = new Lookup();
    $lookup->setItemId($asin);
    $lookup->setResponseGroup(array('Large'));
    // More detailed information
    $response = $apaiIo->runOperation($lookup);
    echo json_encode(simplexml_load_string($response));
});
$app->get('/amazon/similar/:asin', function ($asin) {
    $conf = new GenericConfiguration();
    $conf->setCountry('com')->setAccessKey(getenv('AMAZON_ACCESS'))->setSecretKey(getenv('AMAZON_SECRET'))->setAssociateTag(getenv('AMAZON_ASSOCIATE_TAG'));
    $apaiIo = new ApaiIO($conf);
    $similaritylookup = new SimilarityLookup();
    $similaritylookup->setItemId($asin);
    $response = $apaiIo->runOperation($similaritylookup);
    echo json_encode(simplexml_load_string($response));
});
$app->run();
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Config.php';
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\SimilarityLookup;
$conf = new GenericConfiguration();
try {
    $conf->setCountry('de')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$lookup = new SimilarityLookup();
$lookup->setItemId('B0040PBK32');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
echo $formattedResponse;
echo "<hr>";
// Changing to SOAP and ObjectToArray ResponseTransformer
$conf->setRequest('\\ApaiIO\\Request\\Soap\\Request');
$conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\ObjectToArray');
 /**
  * ApaiIOWrapper constructor.
  * @param array $apiConfig
  */
 public function __construct($apiConfig = array())
 {
     $client = new Client();
     $this->configuration = new GenericConfiguration();
     $this->configuration->setAccessKey($apiConfig['AWS_API_KEY'])->setSecretKey($apiConfig['AWS_API_SECRET_KEY'])->setAssociateTag($apiConfig['AWS_ASSOCIATE_TAG'])->setRequest(new \ApaiIO\Request\GuzzleRequest($client));
 }
Example #19
0
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Config.php';
use ApaiIO\ApaiIO;
use ApaiIO\Configuration\GenericConfiguration;
use ApaiIO\Operations\Lookup;
$conf = new GenericConfiguration();
$client = new \GuzzleHttp\Client();
$request = new \ApaiIO\Request\GuzzleRequest($client);
try {
    $conf->setCountry('de')->setAccessKey(AWS_API_KEY)->setSecretKey(AWS_API_SECRET_KEY)->setAssociateTag(AWS_ASSOCIATE_TAG)->setRequest($request)->setResponseTransformer(new \ApaiIO\ResponseTransformer\XmlToDomDocument());
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$lookup = new Lookup();
$lookup->setItemId('B0040PBK32,B00MEKHLLA');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
var_dump($formattedResponse);
Example #20
0
 public function testSchemeSwitch()
 {
     $body = $this->prophesize('\\Psr\\Http\\Message\\StreamInterface');
     $body->getContents()->shouldBeCalledTimes(1)->willReturn('ABC');
     $response = $this->prophesize('\\Psr\\Http\\Message\\ResponseInterface');
     $response->getBody()->shouldBeCalledTimes(1)->willReturn($body->reveal());
     $client = $this->prophesize('\\GuzzleHttp\\ClientInterface');
     $client->send(Argument::that(function ($request) {
         if (!$request instanceof RequestInterface) {
             return false;
         }
         $uri = $request->getUri();
         $this->assertSame('https', $uri->getScheme());
         return true;
     }))->shouldBeCalledTimes(1)->willReturn($response->reveal());
     $request = new GuzzleRequest($client->reveal());
     $request->setScheme('HTTPS');
     $operation = new Lookup();
     $operation->setItemId('1');
     $config = new GenericConfiguration();
     $config->setAccessKey('abc');
     $config->setAssociateTag('def');
     $config->setCountry('DE');
     $config->setSecretKey('ghi');
     $config->setAccessKey('jkl');
     $request->perform($operation, $config);
 }