KerioConnectApi.php 2.7 KB

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