- Added AssociateProductIncoOutput and SyncProductIncoOutput classes to handle action results. - Updated AssociateProductInco and SyncProductInco actions to return structured output instead of raw models. - Enhanced error handling for API interactions in both actions. - Refactored ProductIncosController to utilize new output structures for better response management. - Introduced new enums for status handling in actions and queries. - Added tests for new output handling and error scenarios in Associate and Sync actions.
41 lines
969 B
PHP
41 lines
969 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cqs\Queries\ProductIncos;
|
|
|
|
use App\Dto\ArcadiaIncoPreviewDto;
|
|
use App\Enums\ArcadiaIncoPreviewStatus;
|
|
|
|
final readonly class GetArcadiaIncoPreviewQueryOutput
|
|
{
|
|
public function __construct(
|
|
public ArcadiaIncoPreviewStatus $status,
|
|
public ?ArcadiaIncoPreviewDto $preview = null,
|
|
public ?string $errorMessage = null,
|
|
) {
|
|
}
|
|
|
|
public static function found(ArcadiaIncoPreviewDto $preview): self
|
|
{
|
|
return new self(
|
|
status: ArcadiaIncoPreviewStatus::FOUND,
|
|
preview: $preview,
|
|
);
|
|
}
|
|
|
|
public static function notFound(): self
|
|
{
|
|
return new self(
|
|
status: ArcadiaIncoPreviewStatus::NOT_FOUND,
|
|
);
|
|
}
|
|
|
|
public static function apiError(string $errorMessage): self
|
|
{
|
|
return new self(
|
|
status: ArcadiaIncoPreviewStatus::API_ERROR,
|
|
errorMessage: $errorMessage,
|
|
);
|
|
}
|
|
}
|