src/Service/Xero/XeroService.php line 19

Open in your IDE?
  1. <?php
  2. // src/Service/UserService.php
  3. namespace App\Service\Xero;
  4. use App\Service\ApiService;
  5. use GuzzleHttp\Client;
  6. use App\Authenticator\XeroAuthenticator;
  7. use XeroAPI\XeroPHP\Configuration;
  8. use XeroAPI\XeroPHP\Api\AccountingApi;
  9. abstract class XeroService extends ApiService 
  10. {
  11.     protected $storage;
  12.     protected $xeroTenantId;
  13.     protected $xeroAccountingManager;
  14.     public function __construct(XeroAuthenticator $xeroAuthenticator)
  15.     {        
  16.         $this->provider $xeroAuthenticator->getProvider();
  17.         $this->storage $xeroAuthenticator->getStorage();
  18.         if ($this->storage) {
  19.             $this->xeroAccountingManager $this->getAccountingApi($this->storage);
  20.             $this->xeroTenantId = (string)$this->storage->getTenantId();
  21.         }
  22.     }
  23.     private function getAccountingApi($currentStorage)
  24.     {
  25.         $config Configuration::getDefaultConfiguration()->setAccessToken((string)$currentStorage->getAccessToken());    
  26.         $xeroAccountingManager = new AccountingApi(
  27.             new Client(),
  28.             $config
  29.         );
  30.         return $xeroAccountingManager;
  31.     }
  32. }