Intuit commands updates

This commit is contained in:
2024-08-12 23:31:59 +10:00
parent bab1f45234
commit 1b581e9feb
2 changed files with 15 additions and 19 deletions

View File

@@ -3,16 +3,17 @@
namespace App\Console\Commands\Intuit;
use Illuminate\Console\Command;
use Intuit\Exceptions\NotTokenException;
use Intuit\Traits\ProviderTokenTrait;
use App\Models\{ProviderOauth,User};
use App\Jobs\AccountingAccountSync as Job;
use App\Jobs\AccountingAccountSync;
/**
* Synchronise Customers with Accounts
*/
class AccountSync extends Command
{
private const provider = 'intuit';
use ProviderTokenTrait;
/**
* The name and signature of the console command.
@@ -33,16 +34,11 @@ class AccountSync extends Command
* Execute the console command.
*
* @return int
* @throws NotTokenException
*/
public function handle()
{
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
if (! ($to=$so->token($uo)))
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
Job::dispatchSync($to);
AccountingAccountSync::dispatchSync($this->providerToken($this->argument('user')));
return self::SUCCESS;
}