<?php

declare(strict_types=1);

namespace App\Models;

/**
 * Result of DELETE /karvipartner/contracts/{contract_id} (Delete contract API).
 */
final class ContractDeleteResult
{
    public function __construct(
        public readonly bool $success,
        public readonly string $message,
        public readonly ?int $deletedId = null,
        public readonly ?array $apiResponse = null,
        public readonly int $httpStatus = 0,
        public readonly ?string $errorCode = null,
    ) {
    }

    /** @param array<string,mixed> $apiResponse */
    public static function ok(
        string $message,
        ?int $deletedId,
        array $apiResponse,
        int $httpStatus = 200
    ): self {
        return new self(
            success: true,
            message: $message,
            deletedId: $deletedId,
            apiResponse: $apiResponse,
            httpStatus: $httpStatus,
        );
    }

    /** @param array<string,mixed>|null $apiResponse */
    public static function fail(
        string $message,
        ?array $apiResponse = null,
        int $httpStatus = 400,
        ?string $errorCode = null
    ): self {
        return new self(
            success: false,
            message: $message,
            apiResponse: $apiResponse,
            httpStatus: $httpStatus,
            errorCode: $errorCode,
        );
    }
}
