<?php

namespace Benhauer\Salesmanago\Helper;

use \Magento\Framework\App\Helper\AbstractHelper;
use \Magento\Framework\App\Helper\Context;
use \Magento\Framework\App\ProductMetadataInterface;

use \Benhauer\Salesmanago\Model\User;
use \Benhauer\Salesmanago\Helper\Config;

class Metrix extends AbstractHelper
{
    protected $productMetadata;
    protected $UserModel;

    public function __construct(
        Context $context,
        User $UserModel,
        ProductMetadataInterface $productMetadata
    ) {
        parent::__construct($context);
        $this->productMetadata = $productMetadata;
        $this->UserModel = $UserModel;
    }

    /**
     * return app metrix data
     */
    public function getJsonConfig()
    {
        $params = [
            'clientId' => $this->UserModel->getClientId(),
            'owner' => $this->UserModel->getOwnerEmail(),
            'platformName' => Config::getPluginPlatform().' '.$this->productMetadata->getEdition(),
            'platformVersion' => $this->productMetadata->getVersion(),
            'pluginVersion' => Config::getPluginVersion()
        ];

        return json_encode($params);
    }
}