From d5a7354df7cf6415edd1e8d2a57173a107d8755b Mon Sep 17 00:00:00 2001 From: Erik K Date: Fri, 18 Nov 2016 16:45:15 +0100 Subject: [PATCH] Create CreateSession.php --- src/pmill/Plesk/CreateSession.php | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/pmill/Plesk/CreateSession.php 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; + } +}