You are here

public function LingotekApi::patchDocument in Lingotek Translation 3.1.x

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

Updates a document in Lingotek.

Parameters

string $id: The document id.

array $args: The document data.

Return value

\Psr\Http\Message\ResponseInterface A response.

Throws

\Drupal\lingotek\Exception\LingotekApiException

Overrides LingotekApiInterface::patchDocument

See also

http://devzone.lingotek.com

File

src/Remote/LingotekApi.php, line 116

Class

LingotekApi
A simple connector to the Lingotek Translation API.

Namespace

Drupal\lingotek\Remote

Code

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