TerminateAccount.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\Http\Actions;
  3. use ThurData\Servers\KerioEmail\App\Enums\Response;
  4. use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
  5. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\DistributionList;
  6. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Domain;
  7. use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
  8. use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
  9. /**
  10. *
  11. * Created by PhpStorm.
  12. * User: Tomasz Bielecki ( tomasz.bi@thurdata.com )
  13. * Date: 09.09.19
  14. * Time: 15:14
  15. * Class TerminateAccount
  16. */
  17. class TerminateAccount extends AddonController
  18. {
  19. use ExtensionsCheckerTrait;
  20. public function execute($params = null)
  21. {
  22. try{
  23. /**
  24. * check if extensions are installed
  25. */
  26. $this->checkExtensionOrThrowError();
  27. /**
  28. * run kerio service
  29. */
  30. $result = $this->kerioRunService($params);
  31. return $result;
  32. }catch (\Exception $ex)
  33. {
  34. /**
  35. * return some crit error
  36. */
  37. return $ex->getMessage();
  38. }
  39. }
  40. /**
  41. * @param null $params
  42. * @return mixed|string
  43. */
  44. protected function kerioRunService($params = null)
  45. {
  46. /**
  47. *
  48. * get soap create domain service
  49. */
  50. $service =(new KerioManager())
  51. ->getApiByServer($params['serverid'])
  52. ->soap
  53. ->service()
  54. ->deleteDomain()
  55. ->setFormData($params)
  56. ;
  57. /**
  58. *
  59. * set params
  60. * run service (Create domain in Kerio API)
  61. */
  62. $result = $service->run();
  63. /**
  64. * check service result & return error
  65. */
  66. if(!$result)
  67. {
  68. return $service->getError();
  69. }
  70. /**
  71. * return success response
  72. */
  73. return Response::SUCCESS;
  74. }
  75. }