<?php
/**
 * Copyright © Simplyin. All rights reserved.
 */
declare(strict_types=1);

namespace Simplyin\Payment\Model;

use Magento\Framework\Model\AbstractModel;

/**
 * Order sync model
 *
 * Tracks synchronization status between Magento and SimplyIN orders
 */
class OrderSync extends AbstractModel
{
    /**
     * Initialize resource model
     *
     * @return void
     */
    protected function _construct(): void
    {
        $this->_init(\Simplyin\Payment\Model\ResourceModel\OrderSync::class);
    }

    /**
     * Get order ID
     *
     * @return int|null
     */
    public function getOrderId(): ?int
    {
        $value = $this->getData('order_id');
        return $value !== null ? (int)$value : null;
    }

    /**
     * Set order ID
     *
     * @param int $orderId
     * @return $this
     */
    public function setOrderId(int $orderId): static
    {
        return $this->setData('order_id', $orderId);
    }

    /**
     * Get SimplyIN order ID
     *
     * @return string|null
     */
    public function getSimplyinOrderId(): ?string
    {
        return $this->getData('simplyin_order_id');
    }

    /**
     * Set SimplyIN order ID
     *
     * @param string $simplyinOrderId
     * @return $this
     */
    public function setSimplyinOrderId(string $simplyinOrderId): static
    {
        return $this->setData('simplyin_order_id', $simplyinOrderId);
    }

    /**
     * Get sync status
     *
     * @return string|null
     */
    public function getSyncStatus(): ?string
    {
        return $this->getData('sync_status');
    }

    /**
     * Set sync status
     *
     * @param string $status
     * @return $this
     */
    public function setSyncStatus(string $status): static
    {
        return $this->setData('sync_status', $status);
    }

    /**
     * Get last sync date
     *
     * @return string|null
     */
    public function getLastSyncAt(): ?string
    {
        return $this->getData('last_sync_at');
    }

    /**
     * Set last sync date
     *
     * @param string $date
     * @return $this
     */
    public function setLastSyncAt(string $date): static
    {
        return $this->setData('last_sync_at', $date);
    }
}
