KerioOperatorApi.php 2.8 KB

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