setRequest() public méthode

Sets the Request.
public setRequest ( ApaiIO\Request\RequestInterface $request ) : GenericConfiguration
$request ApaiIO\Request\RequestInterface
Résultat GenericConfiguration
 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);
 }
 public function testGettersAndSetters()
 {
     $object = new GenericConfiguration();
     $object->setAccessKey('ABC');
     $object->setSecretKey('DEF');
     $object->setAssociateTag('GHI');
     $object->setResponseTransformer($a = new XmlToDomDocument());
     $object->setRequest($b = new GuzzleRequest($this->prophesize('\\GuzzleHttp\\ClientInterface')->reveal()));
     $this->assertSame('ABC', $object->getAccessKey());
     $this->assertSame('DEF', $object->getSecretKey());
     $this->assertSame('GHI', $object->getAssociateTag());
     $this->assertSame($a, $object->getResponseTransformer());
     $this->assertSame($b, $object->getRequest());
 }
 /**
  * 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);
 }
 /**
  * @expectedException LogicException
  */
 public function testInvalidRequestObjectFromObject()
 {
     $conf = new GenericConfiguration();
     $conf->setRequest(new \Exception());
     $request = RequestFactory::createRequest($conf);
 }
Exemple #5
0
// $cartCreate = new CartCreate();
// $cartCreate->addItem("B0040PBK32", 1);
// $formattedResponse = $apaiIO->runOperation($cartCreate);
// $cartAdd = new CartAdd();
// $cartAdd->setCartId('280-6695255-7497359');
// $cartAdd->setHMAC('LxQ0BKVBeQTrzFCXvIoa/262EcU=');
// $cartAdd->addItem('B003YL444A', 1);
// $formattedResponse = $apaiIO->runOperation($cartAdd);
// var_dump($formattedResponse);
$conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\XmlToDomDocument');
$lookup = new Lookup();
$lookup->setItemId('B0040PBK32');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup, $configuration);
//var_dump($formattedResponse);
$lookup = new SimilarityLookup();
$lookup->setItemId('B0040PBK32');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
$conf->setRequest('\\ApaiIO\\Request\\Soap\\Request');
$conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\ObjectToArray');
$lookup = new SimilarityLookup();
$lookup->setItemId('B0040PBK32');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup, $conf);
//var_dump($formattedResponse);
$conf->setResponseTransformer(new \ApaiIO\ResponseTransformer\ObjectToArray());
$browseNodeLookup = new BrowseNodeLookup();
$browseNodeLookup->setNodeId(542064);
$formattedResponse = $apaiIO->runOperation($browseNodeLookup, $configuration);
var_dump($formattedResponse);