<?php

namespace KupShop\ElninoBundle\Resources\script;

use KupShop\AdminBundle\Util\Script\Script;
use KupShop\ElninoBundle\AdWords\AdWordsCampaigns;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class DebugAdWordsCampaignsScript extends Script
{
    protected static $name = 'Debug adWords kampaní - PPC - datová výměna';

    protected static $defaultParameters = [
        'id' => 14165344807,
        'clickthru_url' => 'https://www.parfimo.it/eau-de-toilette-joop-homme_z91/',
        'group_info' => [
            'count_series' => 1,
            'url_type' => 1,
            'sale_info' => 1,
            'variant_info' => 1,
            'volume_info' => 1,
            'discount_info' => 1,
        ],
        'group_params' => [
            'price' => [
                'min' => 6,
                'max' => 0,
            ],
            'volume' => [
                'min' => 30,
                'max' => 0,
            ],
            'sortiment' => [
                'Perfumes',
            ],
            'discount' => [
                'min' => 5,
                'max' => 70,
            ],
        ],
    ];

    protected AdWordsCampaigns $campaigns;

    public function __construct()
    {
        $this->setCampaigns(ServiceContainer::getService(AdWordsCampaigns::class));
    }

    /**
     * @required
     */
    public function setCampaigns(AdWordsCampaigns $campaigns): DebugAdWordsCampaignsScript
    {
        $this->campaigns = $campaigns;

        return $this;
    }

    protected function run(array $arguments)
    {
        $arguments = json_decode(json_encode($arguments));
        $this->log(print_r($this->campaigns->processGroup($arguments), true));
    }
}

return DebugAdWordsCampaignsScript::class;
