<?php

namespace SHServ\Entities;

class DeviceAuth extends \SHServ\Middleware\Entity {
	public static $table_name = "device_auth";
	protected static $fields = [
		"id", "device_id", "device_token", "server_token", "state", "create_at"
	];

	public function __construct(Int $id, Array $data = []){
		parent::__construct(
			self::$table_name,
			$id,
			$data
		);
	}

	public function remove() {
		return $this -> remove_entity();
	}

	public function kill() {
		$this -> state = "killed";
		return $this -> update();
	}

	public function is_active() {
		return $this -> state == "active";
	}
}