You are here

public function Account::getAccounts in GatherContent 7.3

Get list of accounts.

Return value

array Array with accounts.

File

includes/Account.inc, line 66
Contains GatherContent\Accont class.

Class

Account
Class Account.

Namespace

GatherContent

Code

public function getAccounts() {
  $accounts = array();
  try {
    $response = $this->client
      ->get('/accounts');
    if ($response
      ->getStatusCode() === 200) {
      $data = json_decode($response
        ->getBody());
      $accounts = $data->data;
    }
    else {
      drupal_set_message(t("User with provided credentials wasn't found."), 'error');
      $accounts = NULL;
    }
  } catch (\Exception $e) {
    watchdog('gathercontent', $e
      ->getMessage(), array(), WATCHDOG_ERROR);
    drupal_set_message(t("User with provided credentials wasn't found."), 'error');
    $accounts = NULL;
  }
  return $accounts;
}