ApiClient::factory PHP Метод

factory() публичный статический Метод

You can choose between three different api protocols. JSON, XML and SOAP are supported by the zanox api. If no version is given the latest version is always used. --- Usage example: creating api instance use soap api interface and the latest version $api = ApiClient::factory(PROTOCOL_SOAP, VERSION_DEFAULT); use xml api interface and the latest vesion $api = ApiClient::factory(PROTOCOL_XML, VERSION_DEFAULT); use json api interface and latest version $api = ApiClient::factory(PROTOCOL_JSON); ---
public static factory ( string $protocol = PROTOCOL_DEFAULT, string $version = VERSION_DEFAULT ) : mixed
$protocol string api protocol type (XML,JSON or SOAP)
$version string api version is optional
Результат mixed object on successful instantiation or false
    public static function factory($protocol = PROTOCOL_DEFAULT, $version = VERSION_DEFAULT)
    {
        $protocol = strtolower($protocol);
        if (empty(self::$instance[$version][$protocol])) {
            $class = self::getInterface($version, $protocol);
            if ($class) {
                self::$instance[$version][$protocol] = new $class($protocol, $version);
            } else {
                throw new ApiClientException(CLI_ERROR_PROTOCOL_VERSION);
            }
        }
        return self::$instance[$version][$protocol];
    }

Usage Example

Пример #1
0
 /**
  * @param $credentials
  */
 public function login($credentials)
 {
     $api = \ApiClient::factory(PROTOCOL_SOAP, VERSION_2011_03_01);
     $connectId = $credentials['connectid'];
     $secretKey = $credentials['secretkey'];
     $api->setConnectId($connectId);
     $api->setSecretKey($secretKey);
     $this->_apiClient = $api;
 }
All Usage Examples Of ApiClient::factory