<?php

declare(strict_types=1);

namespace Autogedal\PromoRules\Model;

use Autogedal\PromoRules\Api\Data\RuleUsageInterface;
use Magento\Framework\Model\AbstractExtensibleModel;

/**
 * Promo-rule usage model.
 */
class RuleUsage extends AbstractExtensibleModel implements RuleUsageInterface
{
    protected function _construct(): void
    {
        $this->_init(ResourceModel\RuleUsage::class);
    }

    public function getUsageId(): ?int
    {
        return $this->getData(self::USAGE_ID) !== null ? (int) $this->getData(self::USAGE_ID) : null;
    }

    public function setUsageId(?int $usageId): RuleUsageInterface
    {
        return $this->setData(self::USAGE_ID, $usageId);
    }

    public function getRuleId(): ?int
    {
        return $this->getData(self::RULE_ID) !== null ? (int) $this->getData(self::RULE_ID) : null;
    }

    public function setRuleId(?int $ruleId): RuleUsageInterface
    {
        return $this->setData(self::RULE_ID, $ruleId);
    }

    public function getCouponId(): ?int
    {
        return $this->getData(self::COUPON_ID) !== null ? (int) $this->getData(self::COUPON_ID) : null;
    }

    public function setCouponId(?int $couponId): RuleUsageInterface
    {
        return $this->setData(self::COUPON_ID, $couponId);
    }

    public function getNormalizedEmail(): string
    {
        return (string) $this->getData(self::NORMALIZED_EMAIL);
    }

    public function setNormalizedEmail(string $normalizedEmail): RuleUsageInterface
    {
        return $this->setData(self::NORMALIZED_EMAIL, $normalizedEmail);
    }

    public function getTimesUsed(): int
    {
        return (int) $this->getData(self::TIMES_USED);
    }

    public function setTimesUsed(int $timesUsed): RuleUsageInterface
    {
        return $this->setData(self::TIMES_USED, $timesUsed);
    }

    public function getCreatedAt(): ?string
    {
        $value = $this->getData(self::CREATED_AT);
        return $value !== null ? (string) $value : null;
    }

    public function setCreatedAt(?string $createdAt): RuleUsageInterface
    {
        return $this->setData(self::CREATED_AT, $createdAt);
    }

    public function getUpdatedAt(): ?string
    {
        $value = $this->getData(self::UPDATED_AT);
        return $value !== null ? (string) $value : null;
    }

    public function setUpdatedAt(?string $updatedAt): RuleUsageInterface
    {
        return $this->setData(self::UPDATED_AT, $updatedAt);
    }
}
