<?php
namespace WorkbloomERP\Module\v0\Usuario\Models;

use DateTimeImmutable;

class UsuarioSessionModel {
    public function __construct(
        private ?int $id = null,
        private ?string $uuid = null,
        private ?int $usuario_id = null,
        private ?string $user_agent = null,
        private ?string $ip_address = null,
        private ?string $token_hash = null,
        private ?DateTimeImmutable $created_at = null,
        private ?DateTimeImmutable $revoked_at = null,
    ) {}

    public function toArray(): array {
        return [
            'id' => $this->getId(),
            'uuid' => $this->getUuid(),
            'usuario_id' => $this->getUsuarioId(),
            'user_agent' => $this->getUserAgent(),
            'ip_address' => $this->getIpAddress(),
            'token_hash' => $this->getTokenHash(),
            'created_at' => $this->getCreatedAt() ? $this->getCreatedAt()->format('Y-m-d H:i:s') : null,
            'revoked_at' => $this->getRevokedAt() ? $this->getRevokedAt()->format('Y-m-d H:i:s') : null,
        ];
    }

    public function setId(?int $id): void {
        $this->id = $id;
    }
    public function getId(): ?int {
        return $this->id;
    }

    public function setUuid(?string $uuid): void {
        $this->uuid = $uuid;
    }
    public function getUuid(): ?string {
        return $this->uuid;
    }

    public function setUsuarioId(?int $usuario_id): void {
        $this->usuario_id = $usuario_id;
    }
    public function getUsuarioId(): ?int {
        return $this->usuario_id;
    }

    public function setUserAgent(?string $user_agent): void {
        $this->user_agent = $user_agent;
    }
    public function getUserAgent(): ?string {
        return $this->user_agent;
    }

    public function setIpAddress(?string $ip_address): void {
        $this->ip_address = $ip_address;
    }
    public function getIpAddress(): ?string {
        return $this->ip_address;
    }

    public function setTokenHash(?string $token_hash): void {
        $this->token_hash = $token_hash;
    }
    public function getTokenHash(): ?string {
        return $this->token_hash;
    }

    public function setCreatedAt(?DateTimeImmutable $created_at): void {
        $this->created_at = $created_at;
    }
    public function getCreatedAt(): ?DateTimeImmutable {
        return $this->created_at;
    }

    public function setRevokedAt(?DateTimeImmutable $revoked_at): void {
        $this->revoked_at = $revoked_at;
    }
    public function getRevokedAt(): ?DateTimeImmutable {
        return $this->revoked_at;
    }
}