$params */ public function __construct( public readonly string $errorCode, string $message, public readonly int $httpStatus = 422, public readonly array $params = [], ) { parent::__construct($message); } public static function invalidDate(string $value): self { return new self('abcreate_wd_invalid_date', 'Invalid date, expected YYYY-MM-DD.', 422, ['value' => $value]); } public static function invalidInput(string $message): self { return new self('abcreate_wd_invalid_input', $message, 422); } public static function invalidTransition(string $message): self { return new self('abcreate_wd_invalid_transition', $message, 422); } public static function reasonRequired(): self { return new self('abcreate_wd_reason_required', 'A reason is required.', 422); } public static function informativaRequired(): self { return new self( 'abcreate_wd_informativa_required', 'Inform the consumer of the choice between repair and replacement, and of the 12-month extension, before recording the remedy.', 409, ); } public static function refurbishedRequestRequired(): self { return new self( 'abcreate_wd_refurbished_request_required', 'A refurbished replacement needs the consumer\'s explicit request, recorded first.', 409, ); } public static function minorDefect(): self { return new self( 'abcreate_wd_minor_defect', 'The contract cannot be terminated for a minor defect. Confirm the defect is not minor, or record a price reduction.', 422, ); } public static function unitBusy(int $unitId, int $claimId): self { return new self( 'abcreate_wd_unit_busy', sprintf('Unit %d is already in open claim %d.', $unitId, $claimId), 409, ['unit' => $unitId, 'claim' => $claimId], ); } public static function unitsRefunded(int $claimable): self { return new self( 'abcreate_wd_units_refunded', sprintf('Only %d units of this line can be claimed: the others were refunded or are in other claims.', $claimable), 409, ['claimable' => $claimable], ); } public static function deliveryNotConfirmed(): self { return new self( 'abcreate_wd_delivery_not_confirmed', 'Confirm the delivery date before closing the claim as out of warranty.', 409, ); } public static function stillInWarranty(): self { return new self( 'abcreate_wd_still_in_warranty', 'The defect was reported before the end of the legal guarantee.', 409, ); } public static function consumerNotConfirmed(): self { return new self( 'abcreate_wd_consumer_not_confirmed', 'Confirm whether the buyer is a consumer first.', 409, ); } public static function buyerIsConsumer(): self { return new self( 'abcreate_wd_buyer_is_consumer', 'Confirm that the buyer is not a consumer before closing the claim for this reason.', 409, ); } public static function manifestationUnknown(): self { return new self( 'abcreate_wd_manifestation_unknown', 'Record when the defect appeared first: the guarantee looks at that day, not at the day of the report.', 409, ); } public static function remedyRefused(): self { return new self( 'abcreate_wd_remedy_refused', 'Repair and replacement were refused: record a new choice, or close with a price reduction or termination.', 409, ); } public static function versionConflict(int $expected, int $actual): self { return new self( 'abcreate_wd_version_conflict', sprintf('The record changed since it was loaded (expected version %d, current %d). Reload and try again.', $expected, $actual), 409, ['expected' => $expected, 'actual' => $actual], ); } public static function idempotencyRequired(): self { return new self('abcreate_wd_idempotency_required', 'An Idempotency-Key header is required.', 400); } public static function idempotencyMismatch(): self { return new self( 'abcreate_wd_idempotency_mismatch', 'This Idempotency-Key was already used with a different request.', 409, ); } public static function notFound(string $what): self { return new self('abcreate_wd_not_found', sprintf('%s not found.', $what), 404); } }