public function __construct($options)
{
// For retro-compatibility purposes check if $options is a string,
// so if a user passes a string we use it as the app key.
if (is_string($options)) {
$this->apiKey = $options;
} elseif (is_array($options) && !empty($options['apiKey'])) {
trigger_error('API Key has been deprecated by Asana. Please use OAuth or Personal Access Tokens instead', E_USER_DEPRECATED);
$this->apiKey = $options['apiKey'];
} elseif (is_array($options) && !empty($options['personalAccessToken'])) {
$this->personalAccessToken = $options['personalAccessToken'];
} elseif (is_array($options) && !empty($options['accessToken'])) {
$this->accessToken = $options['accessToken'];
} else {
throw new Exception('You need to specify an API key or token');
}
// If the API key is not ended by ":", we append it.
if (!empty($this->apiKey) && substr($this->apiKey, -1) !== ':') {
$this->apiKey .= ':';
}
if (is_array($options) && !empty($options['returnType'])) {
$this->setReturnType($options['returnType']);
}
$this->endPointUrl = 'https://app.asana.com/api/' . $this->asanaApiVersion . '/';
$this->taskUrl = $this->endPointUrl . 'tasks';
$this->userUrl = $this->endPointUrl . 'users';
$this->projectsUrl = $this->endPointUrl . 'projects';
$this->workspaceUrl = $this->endPointUrl . 'workspaces';
$this->teamsUrl = $this->endPointUrl . 'teams';
$this->storiesUrl = $this->endPointUrl . 'stories';
$this->tagsUrl = $this->endPointUrl . 'tags';
$this->organizationsUrl = $this->endPointUrl . 'organizations';
$this->attachmentsUrl = $this->endPointUrl . 'attachments';
$this->webhooksUrl = $this->endPointUrl . 'webhooks';
}