1 <?php
2 /**
3 * This file is part of the kerio-api-php.
4 *
5 * Copyright (c) Kerio Technologies s.r.o.
6 *
7 * For the full copyright and license information, please view
8 * the file license.txt that was distributed with this source code
9 * or visit Developer Zone. (http://www.kerio.com/developers)
10 *
11 * Do not modify this source code.
12 * Any changes may be overwritten by a new version.
13 */
14
15 require_once(dirname(__FILE__) . '/class/KerioApi.php');
16
17 /**
18 * Administration API for Kerio Operator.
19 * STATUS: In progress, might change in the future
20 *
21 * This class implements product-specific methods and properties and currently is under development.
22 * Class is not intended for stable use yet.
23 * Functionality might not be fully verified, documented, or even supported.
24 *
25 * Please note that changes can be made without further notice.
26 *
27 * Example:
28 * <code>
29 * <?php
30 * require_once(dirname(__FILE__) . '/src/KerioOperatorApi.php');
31 *
32 * $api = new KerioOperatorApi('Sample application', 'Company Ltd.', '1.0');
33 *
34 * try {
35 * $api->login('operator.company.tld', 'admin', 'SecretPassword');
36 * $api->sendRequest('...');
37 * $api->logout();
38 * } catch (KerioApiException $error) {
39 * print $error->getMessage();
40 * }
41 * ?>
42 * </code>
43 *
44 * @copyright Copyright © 2012-2012 Kerio Technologies s.r.o.
45 * @license http://www.kerio.com/developers/license/sdk-agreement
46 * @version 1.4.0.234
47 */
48 class KerioOperatorApi extends KerioApi {
49
50 /**
51 * Defines default product-specific JSON-RPC settings
52 * @var array
53 */
54 protected $jsonRpc = array(
55 'version' => '2.0',
56 'port' => 4021,
57 'api' => '/admin/api/jsonrpc/'
58 );
59
60 /**
61 * Class constructor.
62 *
63 * @param string Application name
64 * @param string Application vendor
65 * @param string Application version
66 * @return void
67 * @throws KerioApiException
68 */
69 public function __construct($name, $vendor, $version) {
70 parent::__construct($name, $vendor, $version);
71 }
72
73 /**
74 * Set component Web Administration.
75 *
76 * @param void
77 * @return void
78 */
79 public function setComponentAdmin() {
80 $this->setJsonRpc('2.0', 4021, '/admin/api/jsonrpc/');
81 }
82
83 /**
84 * Set component Client aka MyPhone.
85 *
86 * @param void
87 * @return void
88 */
89 public function setComponentClient() {
90 $this->setJsonRpc('2.0', 443, '/myphone/api/jsonrpc/');
91 }
92
93 /**
94 * Set component MyPhone.
95 *
96 * @param void
97 * @return void
98 * @deprecated
99 */
100 public function setComponentMyphone() {
101 trigger_error("Deprecated function setComponentMyphone(), use setComponentClient() instead", E_USER_NOTICE);
102 $this->setComponentClient();
103 }
104
105 /**
106 * Get constants defined by product.
107 *
108 * @param void
109 * @return array Array of constants
110 */
111 public function getConstants() {
112 $response = $this->sendRequest('Server.getConstantList');
113 return $response['constantList'];
114 }
115 }
116