<?php

declare(strict_types=1);

namespace App\Models;

/**
 * Result of a login attempt against the Karvi Partner API.
 */
final class LoginResult
{
    public function __construct(
        public readonly bool $success,
        public readonly string $message,
        public readonly ?User $user = null,
        public readonly ?array $rawResponse = null,
        public readonly int $httpStatus = 0,
    ) {
    }

    public static function ok(User $user, string $message, array $raw, int $status = 200): self
    {
        return new self(true, $message, $user, $raw, $status);
    }

    public static function fail(string $message, ?array $raw = null, int $status = 401): self
    {
        return new self(false, $message, null, $raw, $status);
    }
}
