diff --git a/src/pmill/Plesk/CreateSession.php b/src/pmill/Plesk/CreateSession.php new file mode 100644 index 0000000..46d6aee --- /dev/null +++ b/src/pmill/Plesk/CreateSession.php @@ -0,0 +1,64 @@ + + + + + {USERNAME} + + {USER_IP} + {SOURCE_SERVER} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'username' => null, + 'user_ip' => null, + 'source_server' => null, + ]; + + /** + * @var string + */ + public $id; + + /** + * @param array $config + * @param array $params + */ + public function __construct(array $config, array $params = []) + { + $params['nodes'] = $this->generateNodeList($params); + parent::__construct($config, $params); + } + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + $result = $xml->server->create_session->result; + + if ($result->status == 'error') { + throw new ApiRequestException($result); + } + + $this->id = (string)$xml->{'server'}->create_session->result->id; + return true; + } +}