<?php

namespace App\Console\Commands;

use App\Libs\Services\ProjectsSyncService;
use Illuminate\Console\Command;

class SyncProjects extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'projects:sync
        {--force : Force sync all projects, hero projecs and projects where the signature didn\'t change}
        {--notify : Notify admin by email if errors}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Syncs all projects with SP API';

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

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle(ProjectsSyncService $service)
    {
        $forceSync = $this->option('force');
        $notify = $this->option('notify');
        $service->syncProjects($forceSync, $notify);
        return 0;
    }
}
