KerioConnectApi.php 2.7 KB

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