<?php

namespace Limb_Chatbot\Includes\Data_Objects;

/**
 * IP block data object.
 *
 * @since 2.0.0
 */
class Ip_Block extends WPDB_Data_Object {

	/**
	 * Database table name.
	 */
	const TABLE_NAME = 'lbaic_ip_blocks';

	/**
	 * Attributes allowed for mass assignment.
	 *
	 * @var array
	 */
	const FILLABLE = [
		'id',
		'ip',
		'location',
		'reason',
		'type',
		'created_at',
		'blocked_until',
		'chatbot_user_id',
	];

	/**
	 * Manual block type.
	 */
	const TYPE_MANUAL = 'manual';

	/**
	 * Automatic block type.
	 */
	const TYPE_AUTOMATIC = 'automatic';

	/**
	 * Primary ID.
	 *
	 * @var int|null
	 */
	public ?int $id = null;

	/**
	 * Blocked IP address.
	 *
	 * @var string
	 */
	public string $ip;

	/**
	 * Human-readable location.
	 *
	 * @var string|null
	 */
	public ?string $location = null;

	/**
	 * Optional block reason.
	 *
	 * @var string|null
	 */
	public ?string $reason = null;

	/**
	 * Block type.
	 *
	 * @var string
	 */
	public string $type = self::TYPE_MANUAL;

	/**
	 * Record creation time.
	 *
	 * @var string
	 */
	public string $created_at;

	/**
	 * Block expiration datetime, null means permanent block.
	 *
	 * @var string|null
	 */
	public ?string $blocked_until = null;

	/**
	 * Related chatbot user ID when block is attached to a known user.
	 *
	 * @var int|null
	 */
	public ?int $chatbot_user_id = null;
}
