Merge pull request 'feat: mail entity download' (#99) from feat/mail-entity-download into main

Reviewed-on: #99
This commit was merged in pull request #99.
This commit is contained in:
2026-05-29 03:05:38 +00:00
2 changed files with 51 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ namespace KTXF\Mail\Service;
use Generator; use Generator;
use KTXF\Mail\Collection\CollectionBaseInterface; use KTXF\Mail\Collection\CollectionBaseInterface;
use KTXF\Mail\Object\AddressInterface; use KTXF\Mail\Object\AddressInterface;
use KTXF\Resource\BinaryResource;
use KTXF\Resource\Delta\Delta; use KTXF\Resource\Delta\Delta;
use KTXF\Resource\Filter\IFilter; use KTXF\Resource\Filter\IFilter;
use KTXF\Resource\Identifier\EntityIdentifierInterface; use KTXF\Resource\Identifier\EntityIdentifierInterface;
@@ -251,7 +252,7 @@ interface ServiceBaseInterface extends ResourceServiceBaseInterface {
*/ */
public function entityFetchBulk(EntityIdentifierInterface ...$identifiers): array; public function entityFetchBulk(EntityIdentifierInterface ...$identifiers): array;
/** /**
* Fetches one or more entities * Fetches one or more entities
* *
* @since 2025.05.01 * @since 2025.05.01
@@ -262,4 +263,16 @@ interface ServiceBaseInterface extends ResourceServiceBaseInterface {
*/ */
public function entityFetchStream(EntityIdentifierInterface ...$identifiers): Generator; public function entityFetchStream(EntityIdentifierInterface ...$identifiers): Generator;
/**
* Downloads a message or part of a message
*
* @since 2025.05.01
*
* @param EntityIdentifierInterface $target Message identifier
* @param array|null $part Optional part to download
*
* @return BinaryResource
*/
public function entityDownload(EntityIdentifierInterface $target, array|null $part): BinaryResource;
} }

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource;
/**
* Carries file-like binary content metadata and a byte stream.
*/
final class BinaryResource
{
public function __construct(
private readonly string $filename,
private readonly string $mimeType,
private readonly \Generator $stream,
) {}
public function filename(): string
{
return $this->filename;
}
public function mimeType(): string
{
return $this->mimeType;
}
public function stream(): \Generator
{
return $this->stream;
}
}