<?php

namespace App\Services\Integrations;

class IntegrationTestResult
{
    public function __construct(
        public bool $ok,
        public string $message,
        public array $data = [],
        public ?int $statusCode = null,
        public ?int $durationMs = null,
    ) {}

    public static function success(string $message, array $data = [], ?int $statusCode = null, ?int $durationMs = null): self
    {
        return new self(true, $message, $data, $statusCode, $durationMs);
    }

    public static function failed(string $message, array $data = [], ?int $statusCode = null, ?int $durationMs = null): self
    {
        return new self(false, $message, $data, $statusCode, $durationMs);
    }

    public function toArray(): array
    {
        return [
            'ok' => $this->ok,
            'message' => $this->message,
            'data' => $this->data,
            'status_code' => $this->statusCode,
            'duration_ms' => $this->durationMs,
        ];
    }
}
