<?php

namespace App\Modules\Notification\Entities;

use CodeIgniter\Entity\Entity;

/**
 * Telegram Account Entity
 * 
 * Represents a Telegram account linked to the system.
 */
class TelegramAccount extends Entity
{
    /**
     * Attributes that can be mass assigned
     * 
     * @var array<string>
     */
    protected $allowedFields = [
        'telegram_user_id',
        'username',
        'first_name',
        'last_name',
        'is_verified',
        'parent_id',
    ];

    /**
     * Attributes that should be cast to specific types
     * 
     * @var array<string, string>
     */
    protected $casts = [
        'id'              => 'integer',
        'telegram_user_id' => 'integer',
        'parent_id'       => 'integer',
        'is_verified'     => 'boolean',
        'created_at'      => 'datetime',
        'updated_at'      => 'datetime',
    ];

    /**
     * Check if account is verified
     * 
     * @return bool
     */
    public function isVerified(): bool
    {
        return (bool) $this->attributes['is_verified'];
    }
}
