Implement IMAP email-to-ticket gateway
This commit is contained in:
1 parent
b7e5884457
commit
6f25869345
33 files changed
+5619
-5
No files matched your search
+69
-4
@@ -6,12 +6,77 @@ namespace Box\Mod\Mailgateway\Api;
|
||||
|
||||
class Admin extends \FOSSBilling\Api\AbstractApi
|
||||
{
|
||||
public function ping(array $data): array
|
||||
public function settings_get(array $data): array
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'module' => 'mailgateway',
|
||||
'version' => '0.1.0',
|
||||
'settings' => $this->getService()->getSettings(),
|
||||
'dependencies' => $this->getService()->getDependencyStatus(),
|
||||
'notifications' => $this->getService()->getNotificationStatus(),
|
||||
'mailboxes' => $this->getService()->getMailboxes(),
|
||||
'helpdesks' => $this->getDi()['mod_service']('support')->getHelpdeskRepository()->getPairs(),
|
||||
];
|
||||
}
|
||||
|
||||
public function settings_save(array $data): bool
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return $this->getService()->saveSettings($data);
|
||||
}
|
||||
|
||||
public function test_connection(array $data): array
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return $this->getService()->testConnection($data);
|
||||
}
|
||||
|
||||
public function install_dependencies(array $data): array
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
$force = $data['force'] ?? false;
|
||||
if (!in_array($force, [true, false, 0, 1, '0', '1'], true)) {
|
||||
throw new \FOSSBilling\InformationException('Invalid dependency installation option');
|
||||
}
|
||||
return $this->getService()->installDependencies(in_array($force, [true, 1, '1'], true));
|
||||
}
|
||||
|
||||
public function setup(array $data): bool
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return $this->getService()->setup();
|
||||
}
|
||||
|
||||
public function notifications_setup(array $data): array
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return $this->getService()->configureNotifications();
|
||||
}
|
||||
|
||||
public function mailbox_delete(array $data): bool
|
||||
{
|
||||
if (!$this->getIdentity() instanceof \Model_Admin) {
|
||||
throw new \FOSSBilling\InformationException('Administrator authentication required');
|
||||
}
|
||||
$this->checkPermissions('mailgateway', 'manage_settings');
|
||||
return $this->getService()->deleteMailbox($data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user