<?php

namespace PortalPeople\AuthRedirect\Model;

use Magento\Framework\Model\AbstractModel;
use Magento\Framework\DataObject\IdentityInterface;

class LoginAttemptLog extends AbstractModel implements IdentityInterface
{
    const CACHE_TAG = 'portalpeople_login_attempt_log';

    protected $_cacheTag = 'portalpeople_login_attempt_log';
    protected $_eventPrefix = 'portalpeople_login_attempt_log';

    protected function _construct()
    {
        $this->_init(\PortalPeople\AuthRedirect\Model\ResourceModel\LoginAttemptLog::class);
    }

    public function getIdentities()
    {
        return [self::CACHE_TAG . '_' . $this->getId()];
    }

    public function getDefaultValues()
    {
        $values = [];
        return $values;
    }

    public function getEmail()
    {
        return $this->getData('email');
    }

    public function setEmail($email)
    {
        return $this->setData('email', $email);
    }

    public function getIpAddress()
    {
        return $this->getData('ip_address');
    }

    public function setIpAddress($ipAddress)
    {
        return $this->setData('ip_address', $ipAddress);
    }

    public function getWasSuccessful()
    {
        return $this->getData('was_successful');
    }

    public function setWasSuccessful($wasSuccessful)
    {
        return $this->setData('was_successful', $wasSuccessful);
    }

    public function getAttemptedAt()
    {
        return $this->getData('attempted_at');
    }

    public function setAttemptedAt($attemptedAt)
    {
        return $this->setData('attempted_at', $attemptedAt);
    }

    // Keep old method names for backward compatibility
    public function getIsSuccessful()
    {
        return $this->getWasSuccessful();
    }

    public function setIsSuccessful($isSuccessful)
    {
        return $this->setWasSuccessful($isSuccessful);
    }

    public function getAttemptTime()
    {
        return $this->getAttemptedAt();
    }

    public function setAttemptTime($attemptTime)
    {
        return $this->setAttemptedAt($attemptTime);
    }
}