<?php

namespace Autogedal\InternalLinks\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;

class Config
{
    const XML_PATH_ENABLED = 'autogedal_internal_links/general/enabled';
    const XML_PATH_BRAND_ATTRIBUTE_ID = 'autogedal_internal_links/general/brand_attribute_id';
    const XML_PATH_MODEL_ATTRIBUTE_ID = 'autogedal_internal_links/general/model_attribute_id';
    const XML_PATH_MODEL_SECONDARY_ATTRIBUTE_ID = 'autogedal_internal_links/general/model_secondary_attribute_id';
    const XML_PATH_MODEL_LIMIT = 'autogedal_internal_links/general/model_limit';
    const XML_PATH_BRAND_LIMIT = 'autogedal_internal_links/general/brand_limit';
    const XML_PATH_PAGE_TITLE = 'autogedal_internal_links/meta_settings/page_title';
    const XML_PATH_META_DESCRIPTION = 'autogedal_internal_links/meta_settings/meta_description';
    const XML_PATH_META_KEYWORDS = 'autogedal_internal_links/meta_settings/meta_keywords';
    const XML_PATH_BRAND_PAGE_TITLE_TEMPLATE = 'autogedal_internal_links/meta_settings/brand_page_title_template';
    const XML_PATH_BRAND_META_TITLE = 'autogedal_internal_links/meta_brand_settings/page_title';
    const XML_PATH_BRAND_META_DESCRIPTION = 'autogedal_internal_links/meta_brand_settings/meta_description';
    const XML_PATH_BRAND_META_KEYWORDS = 'autogedal_internal_links/meta_brand_settings/meta_keywords';

    private $scopeConfig;

    public function __construct(
        ScopeConfigInterface $scopeConfig
    ) {
        $this->scopeConfig = $scopeConfig;
    }

    public function isEnabled($storeId = null)
    {
        return $this->scopeConfig->isSetFlag(
            self::XML_PATH_ENABLED,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandAttributeId($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_BRAND_ATTRIBUTE_ID,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getModelAttributeId($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_MODEL_ATTRIBUTE_ID,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getModelSecondaryAttributeId($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_MODEL_SECONDARY_ATTRIBUTE_ID,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getModelLimit($storeId = null)
    {
        return (int)$this->scopeConfig->getValue(
            self::XML_PATH_MODEL_LIMIT,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandLimit($storeId = null)
    {
        return (int)$this->scopeConfig->getValue(
            self::XML_PATH_BRAND_LIMIT,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getPageTitle($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_PAGE_TITLE,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getMetaDescription($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_META_DESCRIPTION,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getMetaKeywords($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_META_KEYWORDS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandPageTitleTemplate($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_BRAND_PAGE_TITLE_TEMPLATE,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandMetaTitle($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_BRAND_META_TITLE,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandMetaDescription($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_BRAND_META_DESCRIPTION,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }

    public function getBrandMetaKeywords($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_BRAND_META_KEYWORDS,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
}
