<?php

namespace Autogedal\Extend\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Store\Model\ScopeInterface;

class ProductLabelsConfig extends AbstractHelper
{
    const XML_PATH_NEW_PRODUCT_DAYS = 'autogedal/verificator_compatibilitate/new_product_days';
    const XML_PATH_SUPER_DEAL_PERCENTAGE = 'autogedal/verificator_compatibilitate/super_deal_percentage';
    const XML_PATH_LIMITED_STOCK_THRESHOLD = 'autogedal/verificator_compatibilitate/limited_stock_threshold';
    const XML_PATH_BESTSELLER_MONTHS = 'autogedal/verificator_compatibilitate/bestseller_months';
    const XML_PATH_BESTSELLER_MIN_QTY = 'autogedal/verificator_compatibilitate/bestseller_min_qty';

    /**
     * Get number of days for "New" product label
     *
     * @param int|null $storeId
     * @return int
     */
    public function getNewProductDays($storeId = null)
    {
        return (int) $this->scopeConfig->getValue(
            self::XML_PATH_NEW_PRODUCT_DAYS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    /**
     * Get minimum percentage for "Super Deal" label
     *
     * @param int|null $storeId
     * @return float
     */
    public function getSuperDealPercentage($storeId = null)
    {
        return (float) $this->scopeConfig->getValue(
            self::XML_PATH_SUPER_DEAL_PERCENTAGE,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    /**
     * Get stock threshold for "Limited Stock" label
     *
     * @param int|null $storeId
     * @return int
     */
    public function getLimitedStockThreshold($storeId = null)
    {
        return (int) $this->scopeConfig->getValue(
            self::XML_PATH_LIMITED_STOCK_THRESHOLD,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    /**
     * Get number of months for bestseller calculation
     *
     * @param int|null $storeId
     * @return int
     */
    public function getBestsellerMonths($storeId = null)
    {
        return (int) $this->scopeConfig->getValue(
            self::XML_PATH_BESTSELLER_MONTHS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    /**
     * Get minimum quantity for bestseller
     *
     * @param int|null $storeId
     * @return int
     */
    public function getBestsellerMinQty($storeId = null)
    {
        return (int) $this->scopeConfig->getValue(
            self::XML_PATH_BESTSELLER_MIN_QTY,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
}
