You are here

public function Project::__construct in GatherContent 7.3

Account constructor.

Parameters

string $username: API username.

string $api_key: API key.

bool $local: Indicates, if we will need to have client object.

File

includes/Project.inc, line 23

Class

Project

Namespace

GatherContent

Code

public function __construct($username = NULL, $api_key = NULL, $local = FALSE) {
  $this->local = $local;
  if (!$local) {
    if (is_null($username)) {
      $username = variable_get('gathercontent_username', '');
    }
    if (is_null($api_key)) {
      $api_key = variable_get('gathercontent_api_key', '');
    }
    if (empty($username) || empty($api_key)) {
      watchdog('gathercontent', "Trying to call API without credentials.", array(), WATCHDOG_ERROR);
    }
    $this->client = new Client(array(
      'base_url' => 'https://api.gathercontent.com',
      'defaults' => array(
        'auth' => array(
          $username,
          $api_key,
        ),
        'headers' => array(
          'Accept' => 'application/vnd.gathercontent.v0.5+json',
        ),
      ),
    ));
  }
}