chore: standardize protocol
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -226,34 +226,39 @@ class DefaultController extends ControllerAbstract {
|
||||
return match ($operation) {
|
||||
// Provider operations
|
||||
'provider.list' => $this->providerList($tenantId, $userId, $data),
|
||||
'provider.fetch' => $this->providerFetch($tenantId, $userId, $data),
|
||||
'provider.extant' => $this->providerExtant($tenantId, $userId, $data),
|
||||
|
||||
// Service operations
|
||||
'service.list' => $this->serviceList($tenantId, $userId, $data),
|
||||
'service.extant' => $this->serviceExtant($tenantId, $userId, $data),
|
||||
'service.fetch' => $this->serviceFetch($tenantId, $userId, $data),
|
||||
'service.discover' => $this->serviceDiscover($tenantId, $userId, $data),
|
||||
'service.test' => $this->serviceTest($tenantId, $userId, $data),
|
||||
'service.extant' => $this->serviceExtant($tenantId, $userId, $data),
|
||||
'service.create' => $this->serviceCreate($tenantId, $userId, $data),
|
||||
'service.update' => $this->serviceUpdate($tenantId, $userId, $data),
|
||||
'service.delete' => $this->serviceDelete($tenantId, $userId, $data),
|
||||
'service.discover' => $this->serviceDiscover($tenantId, $userId, $data),
|
||||
'service.test' => $this->serviceTest($tenantId, $userId, $data),
|
||||
|
||||
// Collection operations
|
||||
'collection.list' => $this->collectionList($tenantId, $userId, $data),
|
||||
'collection.extant' => $this->collectionExtant($tenantId, $userId, $data),
|
||||
'collection.fetch' => $this->collectionFetch($tenantId, $userId, $data),
|
||||
'collection.extant' => $this->collectionExtant($tenantId, $userId, $data),
|
||||
'collection.create' => $this->collectionCreate($tenantId, $userId, $data),
|
||||
'collection.modify' => $this->collectionModify($tenantId, $userId, $data),
|
||||
'collection.destroy' => $this->collectionDestroy($tenantId, $userId, $data),
|
||||
'collection.update' => $this->collectionUpdate($tenantId, $userId, $data),
|
||||
'collection.delete' => $this->collectionDelete($tenantId, $userId, $data),
|
||||
'collection.delta' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'collection.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
|
||||
// Entity operations
|
||||
'entity.list' => $this->entityList($tenantId, $userId, $data),
|
||||
'entity.delta' => $this->entityDelta($tenantId, $userId, $data),
|
||||
'entity.extant' => $this->entityExtant($tenantId, $userId, $data),
|
||||
'entity.fetch' => $this->entityFetch($tenantId, $userId, $data),
|
||||
'entity.extant' => $this->entityExtant($tenantId, $userId, $data),
|
||||
'entity.create' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'entity.update' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'entity.delete' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'entity.delta' => $this->entityDelta($tenantId, $userId, $data),
|
||||
'entity.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'entity.copy' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
|
||||
'entity.transmit' => $this->entityTransmit($tenantId, $userId, $data),
|
||||
|
||||
default => throw new InvalidArgumentException('Unknown operation: ' . $operation)
|
||||
@@ -289,6 +294,18 @@ class DefaultController extends ControllerAbstract {
|
||||
|
||||
}
|
||||
|
||||
private function providerFetch(string $tenantId, string $userId, array $data): mixed {
|
||||
|
||||
if (!isset($data['identifier'])) {
|
||||
throw new InvalidArgumentException(self::ERR_MISSING_IDENTIFIER);
|
||||
}
|
||||
if (!is_string($data['identifier'])) {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||
}
|
||||
|
||||
return $this->mailManager->providerFetch($tenantId, $userId, $data['identifier']);
|
||||
}
|
||||
|
||||
// ==================== Service Operations =====================
|
||||
|
||||
private function serviceList(string $tenantId, string $userId, array $data): mixed {
|
||||
@@ -536,7 +553,7 @@ class DefaultController extends ControllerAbstract {
|
||||
);
|
||||
}
|
||||
|
||||
private function collectionModify(string $tenantId, string $userId, array $data): mixed {
|
||||
private function collectionUpdate(string $tenantId, string $userId, array $data): mixed {
|
||||
if (!isset($data['provider'])) {
|
||||
throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER);
|
||||
}
|
||||
@@ -562,7 +579,7 @@ class DefaultController extends ControllerAbstract {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
||||
}
|
||||
|
||||
return $this->mailManager->collectionModify(
|
||||
return $this->mailManager->collectionUpdate(
|
||||
$tenantId,
|
||||
$userId,
|
||||
$data['provider'],
|
||||
@@ -572,7 +589,7 @@ class DefaultController extends ControllerAbstract {
|
||||
);
|
||||
}
|
||||
|
||||
private function collectionDestroy(string $tenantId, string $userId, array $data): mixed {
|
||||
private function collectionDelete(string $tenantId, string $userId, array $data): mixed {
|
||||
if (!isset($data['provider'])) {
|
||||
throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER);
|
||||
}
|
||||
@@ -592,7 +609,7 @@ class DefaultController extends ControllerAbstract {
|
||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||
}
|
||||
|
||||
return $this->mailManager->collectionDestroy(
|
||||
return $this->mailManager->collectionDelete(
|
||||
$tenantId,
|
||||
$userId,
|
||||
$data['provider'],
|
||||
|
||||
Reference in New Issue
Block a user