<?php

namespace App\Console\Commands\Intuit;

use Illuminate\Console\Command;
use Intuit\Traits\ProviderTokenTrait;

use App\Jobs\AccountingTaxSync as Job;

/**
 * Synchronise TAX ids with our taxes.
 */
class TaxSync extends Command
{
	use ProviderTokenTrait;

	/**
	 * The name and signature of the console command.
	 *
	 * @var string
	 */
	protected $signature = 'intuit:tax:sync'
		.' {user? : User Email}';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Synchronise taxes with accounting system';

	/**
	 * Execute the console command.
	 *
	 * @return int
	 * @throws \Intuit\Exceptions\NotTokenException
	 */
	public function handle()
	{
		Job::dispatchSync($this->providerToken($this->argument('user')));

		return self::SUCCESS;
	}
}