You are here

public function LingotekApi::getAccountInfo in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  2. 4.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  3. 3.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  4. 3.1.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  5. 3.2.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  6. 3.3.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  7. 3.4.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  8. 3.5.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  9. 3.6.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  10. 3.7.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
  11. 3.8.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()

Overrides LingotekApiInterface::getAccountInfo

File

src/Remote/LingotekApi.php, line 67
Contains \Drupal\lingotek\Remote\LingotekApi.

Class

LingotekApi

Namespace

Drupal\lingotek\Remote

Code

public function getAccountInfo() {
  try {
    $access_token = $this->lingotekClient
      ->getCurrentToken();
    $this->logger
      ->debug('Starting account info request: /auth/oauth2/access_token_info?access_token=%token', [
      '%token' => $access_token,
    ]);
    $response = $this->lingotekClient
      ->get('/auth/oauth2/access_token_info?access_token=' . $access_token);
  } catch (\Exception $e) {
    $this->logger
      ->error('Error requesting account info: %message.', [
      '%message' => $e
        ->getMessage(),
    ]);
    throw new LingotekApiException('Failed to get account info: ' . $e
      ->getMessage());
  }
  $this->logger
    ->debug('getAccountInfo response received, code %code and body %body', [
    '%code' => $response
      ->getStatusCode(),
    '%body' => (string) $response
      ->getBody(TRUE),
  ]);
  return $response;
}