| namespace Biukop; | namespace Biukop; | ||||
| use \XeroPHP\Application\PrivateApplication; | use \XeroPHP\Application\PrivateApplication; | ||||
| use \XeroPHP\Remote\Exception\RateLimitExceededException; | |||||
| class Xero { | class Xero { | ||||
| private $xero; | private $xero; | ||||
| private $clientgroup="48646f3d-cf5e-4fea-8c8b-5812bd540e1b"; | private $clientgroup="48646f3d-cf5e-4fea-8c8b-5812bd540e1b"; | ||||
| //sync users to wordpress system | //sync users to wordpress system | ||||
| //does not work for too many users or employees | //does not work for too many users or employees | ||||
| public function sync_users(){ | public function sync_users(){ | ||||
| $this->sync_clients(); | |||||
| $this->sync_employees(); | |||||
| try{ | |||||
| $this->sync_clients(); | |||||
| $this->sync_employees(); | |||||
| }catch(RateLimitExceededException $e){ | |||||
| $msg= "Xero API rate limit exceeded, please try again later, existing sync within 600 seconds will by passed automatically\n"; | |||||
| $this->logConsole($msg); | |||||
| } | |||||
| } | } | ||||
| private function sync_clients(){ | private function sync_clients(){ | ||||
| $contacts = $this->getClients($this->clientgroup); | $contacts = $this->getClients($this->clientgroup); |