Created
August 13, 2015 09:07
-
-
Save jmsfwk/b1ac9aacd6a42696551d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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