コード例 #1
0
 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);
     }
 }
コード例 #2
0
ファイル: User.php プロジェクト: zawntech/basecamp-api-php
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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();
 }