first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\service\pharmacy;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class EjPharmacyCallbackFailureTransition
|
||||
{
|
||||
/** @param callable(int,array<string,mixed>,string):bool $conditionalUpdate */
|
||||
public static function apply(int $inboxId, string $error, callable $conditionalUpdate): bool
|
||||
{
|
||||
if ($inboxId <= 0) {
|
||||
throw new InvalidArgumentException('callback inbox id is missing');
|
||||
}
|
||||
|
||||
return (bool) Closure::fromCallable($conditionalUpdate)(
|
||||
$inboxId,
|
||||
[
|
||||
'process_status' => 'FAILED',
|
||||
'error_message' => mb_substr($error, 0, 1000),
|
||||
'update_time' => time(),
|
||||
],
|
||||
'PROCESSED'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user