<?php
/**
 * Webkul Software
 *
 * @category  Webkul
 * @package   Webkul_MpPaypal
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
namespace Webkul\MpPaypal\Model\Ui;

use Magento\Checkout\Model\ConfigProviderInterface;
use Webkul\MpPaypal\Gateway\Config\Config;
use Magento\Framework\Locale\ResolverInterface;

class ConfigProvider implements ConfigProviderInterface
{
    const CODE = 'mppaypal';

    /**
     * @var Config
     */
    private $config;

    /**
     * @var Magento\Store\Api\Data\StoreInterface
     */
    protected $store;

    /**
     * @var \Magento\Customer\Model\Session
     */
    protected $customerSession;

    /**
     * Constructor
     *
     * @param Config $config
     * @param PayPalConfig $payPalConfig No longer used by internal code and not recommended.
     * @param BraintreeAdapter $adapter
     * @param ResolverInterface $localeResolver No longer used by internal code and not recommended.
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function __construct(
        Config $config,
        ResolverInterface $localeResolver,
        \Magento\Store\Api\Data\StoreInterface $store,
        \Magento\Framework\UrlInterface $urlInterface,
        \Magento\Customer\Model\Session $customerSession
    ) {
        $this->config = $config;
        $this->store = $store;
        $this->urlInterface = $urlInterface;
        $this->customerSession = $customerSession;
    }

    /**
     * Retrieve assoc array of checkout configuration
     *
     * @return array
     */
    public function getConfig()
    {
        return [
            'payment' => [
                self::CODE => [
                    'isActive' => $this->config->isActive($this->store->getId()),
                    'environment' => $this->config->getEnvironment(),
                    'locale' => strtolower($this->store->getLocaleCode()),
                    'createOrderUrl' => $this->urlInterface->getUrl('mppaypal/seller/createorder'),
                    'captureOrderUrl' => $this->urlInterface->getUrl('mppaypal/seller/captureorder')
                ]
            ]
        ];
    }
}
