Skip to content

Commit

Permalink
Add getTenants() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr authored Sep 15, 2021
1 parent 089e696 commit 154ae01
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/XeroFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class XeroFactory
*/
protected $application;

/**
* @var \Calcinai\OAuth2\Client\XeroTenant[]
*/
protected $tenants = [];

/**
* Setup
*/
Expand All @@ -37,6 +42,7 @@ public function setupApplication()
$config->XeroRefreshToken = $refresh;
}

$this->tenants = $provider->getTenants($newAccessToken);
$config->write();
}

Expand Down Expand Up @@ -74,4 +80,16 @@ public function getRedirectUri()
'connectXero'
);
}

/**
* @return \Calcinai\OAuth2\Client\XeroTenant[]
*/
public function getTenants()
{
if (!$this->application) {
$this->setupApplication();
}

return $this->tenants;
}
}

0 comments on commit 154ae01

Please sign in to comment.