Intuit commands updates
This commit is contained in:
parent
bab1f45234
commit
1b581e9feb
@ -3,14 +3,16 @@
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Intuit\Exceptions\NotTokenException;
|
||||
use Intuit\Jobs\AccountingCustomerUpdate;
|
||||
use Intuit\Models\Customer as AccAccount;
|
||||
use Intuit\Traits\ProviderTokenTrait;
|
||||
|
||||
use App\Models\{Account,ProviderOauth,User};
|
||||
use App\Models\Account;
|
||||
|
||||
class AccountAdd extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
use ProviderTokenTrait;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@ -32,15 +34,10 @@ class AccountAdd 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));
|
||||
|
||||
$o = Account::findOrFail($this->argument('id'));
|
||||
|
||||
$acc = new AccAccount;
|
||||
@ -53,6 +50,9 @@ class AccountAdd extends Command
|
||||
$acc->FullyQualifiedName = $o->name;
|
||||
$acc->Active = (bool)$o->active;
|
||||
|
||||
return AccountingCustomerUpdate::dispatchSync($to,$acc);
|
||||
return AccountingCustomerUpdate::dispatchSync(
|
||||
$this->providerToken($this->argument('user')),
|
||||
$acc
|
||||
);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user