mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
separate auth logic from entity logic
This commit is contained in:
parent
af47d5d8e4
commit
b3ab9e468c
37
app/Services/Import/Quickbooks/Auth.php
Normal file
37
app/Services/Import/Quickbooks/Auth.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace App\Services\Import\Quickbooks;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Services\Import\QuickBooks\Contracts\SDKInterface as QuickbooksInterface;
|
||||
|
||||
final class Auth
|
||||
{
|
||||
private QuickbooksInterface $sdk;
|
||||
|
||||
public function __construct(QuickbooksInterface $quickbooks) {
|
||||
$this->sdk = $quickbooks;
|
||||
}
|
||||
|
||||
public function accessToken(string $code, string $realm ) : array
|
||||
{
|
||||
// TODO: Get or put token in Cache or DB?
|
||||
return $this->sdk->accessToken($code, $realm);
|
||||
}
|
||||
|
||||
public function refreshToken() : array
|
||||
{
|
||||
// TODO: Get or put token in Cache or DB?
|
||||
return $this->sdk->refreshToken();
|
||||
}
|
||||
|
||||
public function getAuthorizationUrl(): string
|
||||
{
|
||||
return $this->sdk->getAuthorizationUrl();
|
||||
}
|
||||
|
||||
public function getState() : string
|
||||
{
|
||||
return $this->sdk->getState();
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ namespace App\Services\Import\Quickbooks;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Services\Import\Quickbooks\Auth;
|
||||
use App\Repositories\Import\Quickbooks\Contracts\RepositoryInterface;
|
||||
use App\Services\Import\QuickBooks\Contracts\SdkInterface as QuickbooksInterface;
|
||||
|
||||
@ -14,6 +15,11 @@ final class Service
|
||||
$this->sdk = $quickbooks;
|
||||
}
|
||||
|
||||
public function getOAuth() : Auth
|
||||
{
|
||||
return new Auth($this->sdk);
|
||||
}
|
||||
|
||||
public function getAccessToken() : array
|
||||
{
|
||||
// TODO: Cache token and
|
||||
|
Loading…
x
Reference in New Issue
Block a user