public function testCanGetAuthorizationObject() { if ($this->config->authenticationType == \Zawntech\BasecampAPI\Auth\Types\AuthType::OAUTH) { $this->authorization->load(); $this->assertNotEmpty($this->authorization->accounts); $this->assertNotEmpty($this->authorization->identity); } }
/** * Return a user's Basecamp Account ID. * @return bool|string * @throws \Exception */ public function getAccountId() { // If module type if basic http, return the account ID specified in the configuration. if (Config::getInstance()->authenticationType == AuthType::BASIC_HTTP) { // If using Basic Http, a specified account ID is required in the configuration. if (empty(Config::getInstance()->accountId)) { throw new \Exception('No account ID set in configuration!'); } // Return the account ID from configuration. return Config::getInstance()->accountId; } if (Config::getInstance()->authenticationType == AuthType::OAUTH) { $auth = new Authorization(); $auth->load(); foreach ($auth->accounts as $account) { if ($account->product == "bcx") { return $account->id; } } } return false; }
/** * Returns a Basecamp authorization object, as in: * https://github.com/basecamp/api/blob/master/sections/authentication.md#get-authorization * @return string * @throws \Exception */ public function requestAuthorizationModel() { return Authorization::getAuthorization(); }