/** * @param $consoleCommand SyncCommandBase * @param bool $forceReload * @return array|null */ public static function retrieveHelpscoutUsers($forceReload = false) { if (!self::$consoleCommand) { throw new Exception("Console command not set prior to invoking APIHelper methods!"); } if (self::$helpscoutUsers && !$forceReload) { return self::$helpscoutUsers; } $pageNumber = 1; $cumulativeHelpscoutUsers = array(); $consoleCommand = self::$consoleCommand; try { do { /* @var $helpscoutUsersResponse Collection */ $helpscoutUsersResponse = self::$consoleCommand->makeRateLimitedRequest(HELPSCOUT, function () use($consoleCommand, $pageNumber) { return $consoleCommand->getHelpScoutClient()->getUsers(['page' => $pageNumber]); }); $cumulativeHelpscoutUsers = array_merge($cumulativeHelpscoutUsers, $helpscoutUsersResponse->getItems()); $pageNumber++; } while ($helpscoutUsersResponse->hasNextPage()); } catch (ApiException $e) { $consoleCommand->error("Failed to retrieve HelpScout users. Message was: " . static::formatApiExceptionArray($e)); } self::$helpscoutUsers = $cumulativeHelpscoutUsers; return $cumulativeHelpscoutUsers; }
/** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); APIHelper::setConsoleCommand($this); date_default_timezone_set('America/Toronto'); }
/** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); }