You are here

public function LingotekApi::getDocumentInfo in Lingotek Translation 3.4.x

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

Gets the document information from the Lingotek service.

Parameters

string $id: The document id.

Return value

\Psr\Http\Message\ResponseInterface A response.

Overrides LingotekApiInterface::getDocumentInfo

File

src/Remote/LingotekApi.php, line 199

Class

LingotekApi
A simple connector to the Lingotek Translation API.

Namespace

Drupal\lingotek\Remote

Code

public function getDocumentInfo($id) {
  try {
    $this->logger
      ->debug('Lingotek::getDocumentInfo called with id ' . $id);
    $response = $this->lingotekClient
      ->get('/api/document/' . $id);
  } catch (\Exception $e) {
    $this->logger
      ->error('Error getting document info: %message.', [
      '%message' => $e
        ->getMessage(),
    ]);
    throw new LingotekApiException('Failed to get document: ' . $e
      ->getMessage());
  }
  $this->logger
    ->debug('getDocumentInfo response received, code %code and body %body', [
    '%code' => $response
      ->getStatusCode(),
    '%body' => (string) $response
      ->getBody(TRUE),
  ]);
  return $response;
}