Skip to content

Instantly share code, notes, and snippets.

@jmsfwk
Created August 13, 2015 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmsfwk/b1ac9aacd6a42696551d to your computer and use it in GitHub Desktop.
Save jmsfwk/b1ac9aacd6a42696551d to your computer and use it in GitHub Desktop.
<?php
use Phalcon\Di\InjectionAwareInterface;
use Phalcon\DiInterface;
class EbayClient extends SoapClient implements InjectionAwareInterface
{
protected $di;
protected $config;
public function __construct($wsdl = null, $options = array())
{
if(!isset($options["config"])) {
throw new \Exception("eBay specific options must be set");
} else {
$this->config = $options["config"];
unset($options["config"]);
}
parent::__construct($wsdl, array_merge_recursive(array("trace" => true), $options));
$requesterCredentials = array('eBayAuthToken' => $this->config->token);
$header = new SoapHeader('urn:ebay:apis:eBLBaseComponents', 'RequesterCredentials', $requesterCredentials);
$this->__setSoapHeaders($header);
}
public function setDI(DiInterface $dependencyInjector)
{
$this->_di = $dependencyInjector;
}
public function getDI()
{
return $this->di;
}
public function __call($function_name, $aguments = array())
{
$config = $this->config;
if(!array_key_exists("Version", $aguments[0])) {
$aguments[0]["Version"] = $config->version;
} else {
$config->version = $aguments[0]["Version"];
}
$queryString = http_build_query(array(
"callname" => $function_name,
"appid" => $config->appid,
"version" => $config->version,
"siteid" => $config->siteid,
"Routing" => "new"
));
$this->__setLocation($config->endpoint . '?' . $queryString);
return $this->__soapCall($function_name, $aguments);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment