Exeu/apai-io

Response Object doesn't make sense.

juanmrad opened this issue · 1 comments

My code:

<?php
require_once '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('com')
        ->setAccessKey('ACESS KEY')
        ->setSecretKey('SECRET KEY')
        ->setAssociateTag('ASSOCIATE TAG')
        ->setRequest($request)
        ->setResponseTransformer(new \ApaiIO\ResponseTransformer\XmlToSimpleXmlObject());
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);
$lookup = new Lookup();
$lookup->setItemId('B01DVCI34I');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
var_dump($formattedResponse);

I'm trying to get a response I can use to as an array or to browse into and get data to a database table.

I've been trying to find the example shown in the github: http://apaiio.dev.pixel-web.org/ but haven't found any files containing that example. I don't see how to handle the response as a XML or json not a simplexml object.

Exeu commented

There is no array any more.
You need to create an array inside of a transformer.

What you saw was the documentation from version 1 of this lib.
Version 2 does not offer an "array transformer" anymore.