setResponseTransformer() 공개 메소드

Sets the ResponseTransformer
public setResponseTransformer ( ApaiIO\ResponseTransformer\ResponseTransformerInterface $responseTransformer ) : GenericConfiguration
$responseTransformer ApaiIO\ResponseTransformer\ResponseTransformerInterface
리턴 GenericConfiguration
예제 #1
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);
 }
예제 #2
0
 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());
 }
예제 #3
0
 /**
  * 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);
 }
예제 #4
0
$search->setPage(3);
$search->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($search);
echo $formattedResponse;
exit;
// var_dump($formattedResponse);
// $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);
예제 #5
0
 /**
  * @expectedException LogicException
  */
 public function testInvalidRequestFactoryCallbackReturnValue()
 {
     $conf = new GenericConfiguration();
     $conf->setResponseTransformer('\\ApaiIO\\ResponseTransformer\\XmlToDomDocument');
     $conf->setResponseTransformerFactory(function ($response) {
         return new \stdClass();
     });
     ResponseTransformerFactory::createResponseTransformer($conf);
 }
예제 #6
0
 * 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');
$lookup = new SimilarityLookup();
$lookup->setItemId('B0040PBK32');
$lookup->setResponseGroup(array('Large', 'Small'));
$formattedResponse = $apaiIO->runOperation($lookup);
var_dump($formattedResponse);
예제 #7
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\BrowseNodeLookup;
$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);
// Changing to SOAP and ObjectToArray ResponseTransformer
$conf->setRequest('\\ApaiIO\\Request\\Soap\\Request');
$conf->setResponseTransformer(new \ApaiIO\ResponseTransformer\ObjectToArray());
$browseNodeLookup = new BrowseNodeLookup();
$browseNodeLookup->setNodeId(542064);
$formattedResponse = $apaiIO->runOperation($browseNodeLookup);
var_dump($formattedResponse);
예제 #8
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);