DictionariesLoad.php 1.23 KB
<?php

namespace App\Console\Commands;

use App\Models\Tokens;
use App\Service\API\API;
use App\Service\Direct\CheckDictionaries;
use App\Service\Direct\GetCampaigns;
use App\Service\Requests\APIRequest;
use Illuminate\Console\Command;

class DictionariesLoad extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dictionaries:load';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Обновление справочника городов';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     * @throws \Exception
     */
    public function handle()
    {
        $token = Tokens::where('type', Tokens::MAIN)->first();
        if (!$token) {
            throw new \Exception('Не найден токен блин');
        }

        $factory = APIRequest::getInstance(API::YANDEX);
        $factory->setToken($token);

        $factory->getRequest('dictionaries', 'get')
            ->call();

        return 0;
    }
}