setResponseTransformer() public method

Sets the ResponseTransformer
public setResponseTransformer ( ApaiIO\ResponseTransformer\ResponseTransformerInterface $responseTransformer ) : GenericConfiguration
$responseTransformer ApaiIO\ResponseTransformer\ResponseTransformerInterface
return GenericConfiguration
コード例 #1
0
ファイル: ApaiIOCoreTest.php プロジェクト: jdgriffith/apai-io
 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
ファイル: sample1.php プロジェクト: njbhatt18/Amazon_API
$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
ファイル: SimpleLookup.php プロジェクト: jdgriffith/apai-io
* 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);