Initial commit

This commit is contained in:
root
2026-01-04 22:05:37 -05:00
committed by Sebastian Krupinski
commit 4f979ced22
57 changed files with 11076 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Contacts;
use JmapClient\Requests\RequestParameters;
class ContactEmailParameters extends RequestParameters {
public function __construct(&$parameters = null) {
parent::__construct($parameters);
}
public function type(string $value): self {
$this->parameter('type', $value);
return $this;
}
public function value(string $value): self {
$this->parameter('value', $value);
return $this;
}
public function label(string $value): self {
$this->parameter('label', $value);
return $this;
}
public function default(bool $value): self {
$this->parameter('isDefault', $value);
return $this;
}
}

View File

@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Contacts;
use JmapClient\Requests\RequestParameters;
class ContactLocationParameters extends RequestParameters {
public function __construct(&$parameters = null) {
parent::__construct($parameters);
}
public function type(string $value): self {
$this->parameter('type', $value);
return $this;
}
public function label(string $value): self {
$this->parameter('label', $value);
return $this;
}
public function street(string $value): self {
$this->parameter('street', $value);
return $this;
}
public function locality(string $value): self {
$this->parameter('locality', $value);
return $this;
}
public function region(string $value): self {
$this->parameter('region', $value);
return $this;
}
public function code(string $value): self {
$this->parameter('postcode', $value);
return $this;
}
public function country(string $value): self {
$this->parameter('country', $value);
return $this;
}
public function default(bool $value): self {
$this->parameter('isDefault', $value);
return $this;
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Contacts;
use JmapClient\Requests\RequestParameters;
class ContactOnlineParameters extends RequestParameters {
public function __construct(&$parameters = null) {
parent::__construct($parameters);
}
public function type(string $value): self {
$this->parameter('type', $value);
return $this;
}
public function value(string $value): self {
$this->parameter('value', $value);
return $this;
}
public function label(string $value): self {
$this->parameter('label', $value);
return $this;
}
}

View File

@@ -0,0 +1,171 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Contacts;
use JmapClient\Requests\RequestParameters;
use function PHPUnit\Framework\isEmpty;
class ContactParameters extends RequestParameters {
public const DATE_FORMAT_ANNIVERSARY = 'YYYY-MM-DD';
public function __construct(&$parameters = null) {
parent::__construct($parameters);
}
public function in(string $value): self {
if (isEmpty($value)) {
$this->parameter('addressbookId', 'Default');
} else {
$this->parameter('addressbookId', $value);
}
return $this;
}
public function id(string $value): self {
$this->parameter('id', $value);
return $this;
}
public function uid(string $value): self {
$this->parameter('uid', $value);
return $this;
}
public function type(string $value): self {
$this->parameter('kind', $value);
return $this;
}
public function nameLast(string $value): self {
$this->parameter('lastName', $value);
return $this;
}
public function nameFirst(string $value): self {
$this->parameter('firstName', $value);
return $this;
}
public function namePrefix(string $value): self {
$this->parameter('prefix', $value);
return $this;
}
public function nameSuffix(string $value): self {
$this->parameter('suffix', $value);
return $this;
}
public function organizationName(string $value): self {
$this->parameter('company', $value);
return $this;
}
public function organizationUnit(string $value): self {
$this->parameter('department', $value);
return $this;
}
public function title(string $value): self {
$this->parameter('jobTitle', $value);
return $this;
}
public function notes(string $value): self {
$this->parameter('notes', $value);
return $this;
}
public function priority(int $value): self {
$this->parameter('importance', $value);
return $this;
}
public function birthDay(string $value): self {
$this->parameter('birthday', $value);
return $this;
}
public function nuptialDay(string $value): self {
$this->parameter('anniversary', $value);
return $this;
}
public function email(?int $id = null): ContactEmailParameters {
// Ensure the parameter exists
if (!isset($this->_parameters->emails)) {
$this->_parameters->emails = [];
}
// If an ID is provided, ensure the specific email entry exists
if ($id !== null) {
if (!isset($this->_parameters->emails[$id])) {
$this->_parameters->emails[$id] = new \stdClass();
}
return new ContactEmailParameters($this->_parameters->emails[$id]);
}
// If no ID is provided, create a new email entry
$this->_parameters->emails[] = new \stdClass();
return new ContactEmailParameters(end($this->_parameters->emails));
}
public function phone(?int $id = null): ContactPhoneParameters {
// Ensure the parameter exists
if (!isset($this->_parameters->phones)) {
$this->_parameters->phones = [];
}
// If an ID is provided, ensure the specific phone entry exists
if ($id !== null) {
if (!isset($this->_parameters->phones[$id])) {
$this->_parameters->phones[$id] = new \stdClass();
}
return new ContactPhoneParameters($this->_parameters->phones[$id]);
}
// If no ID is provided, create a new phone entry
$this->_parameters->phones[] = new \stdClass();
return new ContactPhoneParameters(end($this->_parameters->phones));
}
public function location(?int $id = null): ContactLocationParameters {
// Ensure the parameter exists
if (!isset($this->_parameters->addresses)) {
$this->_parameters->addresses = [];
}
// If an ID is provided, ensure the specific address entry exists
if ($id !== null) {
if (!isset($this->_parameters->addresses[$id])) {
$this->_parameters->addresses[$id] = new \stdClass();
}
return new ContactLocationParameters($this->_parameters->addresses[$id]);
}
// If no ID is provided, create a new address entry
$this->_parameters->addresses[] = new \stdClass();
return new ContactLocationParameters(end($this->_parameters->addresses));
}
public function online(?int $id = null): ContactOnlineParameters {
// Ensure the parameter exists
if (!isset($this->_parameters->addresses)) {
$this->_parameters->addresses = [];
}
// If an ID is provided, ensure the specific address entry exists
if ($id !== null) {
if (!isset($this->_parameters->addresses[$id])) {
$this->_parameters->addresses[$id] = new \stdClass();
}
return new ContactOnlineParameters($this->_parameters->addresses[$id]);
}
// If no ID is provided, create a new address entry
$this->_parameters->addresses[] = new \stdClass();
return new ContactOnlineParameters(end($this->_parameters->addresses));
}
}

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Contacts;
use JmapClient\Requests\RequestParameters;
class ContactPhoneParameters extends RequestParameters {
public function __construct(&$parameters = null) {
parent::__construct($parameters);
}
public function type(string $value): self {
$this->parameter('type', $value);
return $this;
}
public function value(string $value): self {
$this->parameter('value', $value);
return $this;
}
public function label(string $value): self {
$this->parameter('label', $value);
return $this;
}
public function default(bool $value): self {
$this->parameter('isDefault', $value);
return $this;
}
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Request\Events;
use JmapClient\Requests\Calendar\EventFilter as EventFilterJmap;
class EventFilter extends EventFilterJmap {
public function in(string $value): self {
$this->condition('inCalendars', [$value]);
return $this;
}
}

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Response\Contacts;
use JmapClient\Responses\ResponseParameters;
class ContactEmailParameters extends ResponseParameters {
public function type(): ?string {
return $this->parameter('type') ?? 'personal';
}
public function value(): ?string {
return $this->parameter('value');
}
public function label(): ?string {
return $this->parameter('label');
}
public function default(): bool {
return $this->parameter('isDefault');
}
}

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Response\Contacts;
use JmapClient\Responses\ResponseParameters;
class ContactLocationParameters extends ResponseParameters {
public function type(): ?string {
return $this->parameter('type') ?? 'home';
}
public function label(): ?string {
return $this->parameter('label');
}
public function street(): ?string {
return $this->parameter('street');
}
public function locality(): ?string {
return $this->parameter('locality');
}
public function region(): ?string {
return $this->parameter('region');
}
public function code(): ?string {
return $this->parameter('postcode');
}
public function country(): ?string {
return $this->parameter('country');
}
}

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Response\Contacts;
use JmapClient\Responses\ResponseParameters;
class ContactOnlineParameters extends ResponseParameters {
public function type(): ?string {
return $this->parameter('type') ?? 'other';
}
public function value(): ?string {
return $this->parameter('value');
}
public function label(): ?string {
return $this->parameter('label');
}
}

View File

@@ -0,0 +1,115 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Response\Contacts;
use JmapClient\Responses\ResponseParameters;
class ContactParameters extends ResponseParameters {
/* Metadata Properties */
public function in(): ?array {
// return value of parameter
$value = $this->parameter('addressbookId');
if ($value !== null) {
return [$value];
}
return null;
}
public function id(): ?string {
return $this->parameter('id');
}
public function uid(): ?string {
return $this->parameter('uid');
}
public function type(): ?string {
return $this->parameter('kind') ?? 'individual';
}
public function nameLast(): ?string {
return $this->parameter('lastName');
}
public function nameFirst(): ?string {
return $this->parameter('firstName');
}
public function namePrefix(): ?string {
return $this->parameter('prefix');
}
public function nameSuffix(): ?string {
return $this->parameter('suffix');
}
public function organizationName(): ?string {
return $this->parameter('company');
}
public function organizationUnit(): ?string {
return $this->parameter('department');
}
public function title(): ?string {
return $this->parameter('jobTitle');
}
public function notes(): ?string {
return $this->parameter('notes');
}
public function priority(): ?int {
return (int)$this->parameter('importance');
}
public function birthDay(): ?string {
return $this->parameter('birthday');
}
public function nuptialDay(): ?string {
return $this->parameter('anniversary');
}
public function email(): array {
$collection = $this->parameter('emails') ?? [];
foreach ($collection as $key => $data) {
$collection[$key] = new ContactEmailParameters($data);
}
return $collection;
}
public function phone(): array {
$collection = $this->parameter('phones') ?? [];
foreach ($collection as $key => $data) {
$collection[$key] = new ContactPhoneParameters($data);
}
return $collection;
}
public function location(): array {
$collection = $this->parameter('addresses') ?? [];
foreach ($collection as $key => $data) {
$collection[$key] = new ContactLocationParameters($data);
}
return $collection;
}
public function online(): array {
$collection = $this->parameter('online') ?? [];
foreach ($collection as $key => $data) {
$collection[$key] = new ContactOnlineParameters($data);
}
return $collection;
}
}

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXM\ProviderJmapc\Jmap\FM\Response\Contacts;
use JmapClient\Responses\ResponseParameters;
class ContactPhoneParameters extends ResponseParameters {
public function type(): ?string {
return $this->parameter('type') ?? 'home';
}
public function value(): ?string {
return $this->parameter('value');
}
public function label(): ?string {
return $this->parameter('label');
}
public function default(): bool {
return (bool)$this->parameter('isDefault');
}
}