72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace KTXM\ProviderJmapc\Providers\Mail;
|
|
|
|
use KTXF\Mail\Collection\CollectionPropertiesMutableAbstract;
|
|
|
|
/**
|
|
* Mail Collection Properties Implementation
|
|
*/
|
|
class CollectionProperties extends CollectionPropertiesMutableAbstract {
|
|
|
|
/**
|
|
* Convert JMAP parameters array to mail collection properties object
|
|
*
|
|
* @param array $parameters JMAP parameters array
|
|
*/
|
|
public function fromJmap(array $parameters): static {
|
|
|
|
if (isset($parameters['totalEmails'])) {
|
|
$this->data['total'] = $parameters['totalEmails'];
|
|
}
|
|
if (isset($parameters['unreadEmails'])) {
|
|
$this->data['unread'] = $parameters['unreadEmails'];
|
|
}
|
|
if (isset($parameters['name'])) {
|
|
$this->data['label'] = $parameters['name'];
|
|
}
|
|
if (isset($parameters['role'])) {
|
|
$this->data['role'] = $parameters['role'];
|
|
}
|
|
if (isset($parameters['sortOrder'])) {
|
|
$this->data['rank'] = $parameters['sortOrder'];
|
|
}
|
|
if (isset($parameters['isSubscribed'])) {
|
|
$this->data['subscribed'] = $parameters['isSubscribed'];
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Convert mail collection properties object to JMAP parameters array
|
|
*/
|
|
public function toJmap(): array {
|
|
|
|
$parameters = [];
|
|
|
|
if (isset($this->data['label'])) {
|
|
$parameters['name'] = $this->data['label'];
|
|
}
|
|
if (isset($this->data['role'])) {
|
|
$parameters['role'] = $this->data['role'];
|
|
}
|
|
if (isset($this->data['rank'])) {
|
|
$parameters['sortOrder'] = $this->data['rank'];
|
|
}
|
|
if (isset($this->data['subscribed'])) {
|
|
$parameters['isSubscribed'] = $this->data['subscribed'];
|
|
}
|
|
|
|
return $parameters;
|
|
}
|
|
|
|
}
|