Changed way to connect to api
This commit is contained in:
@ -83,16 +83,25 @@ class Mailboxes
|
||||
$body = $request->getBody();
|
||||
$json = \Safe\json_decode($body->getContents());
|
||||
if (!isset($json->mailboxes)) {
|
||||
throw new MissingArgument('mailboxes', 'array', 'mailboxes names');
|
||||
throw new MissingArgument('mailboxes', 'array', 'mailboxes ids');
|
||||
}
|
||||
$output = [
|
||||
'mailboxes' => $json->mailboxes,
|
||||
'total' => count($json->mailboxes),
|
||||
'unregistered' => 0
|
||||
'unregistered' => [
|
||||
'total' => 0,
|
||||
'mailboxes' => []
|
||||
]
|
||||
];
|
||||
foreach ($json->mailboxes as $mailbox_name) {
|
||||
if ($service->unregister($mailbox_name)) {
|
||||
$output['unregistered'] ++;
|
||||
foreach ($json->mailboxes as $mailbox_id) {
|
||||
$mailbox = $service->getRepository()->fetchById($mailbox_id);
|
||||
if ($service->unregister($mailbox->getName())) {
|
||||
$output['unregistered']['total'] ++;
|
||||
$output['unregistered']['mailboxes'] []= [
|
||||
'id' => $mailbox->getId(),
|
||||
'name' => $mailbox->getName(),
|
||||
'unregistered' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
|
Reference in New Issue
Block a user