Skip to content

Commit

Permalink
Add session id support
Browse files Browse the repository at this point in the history
  • Loading branch information
davc0n committed Jun 14, 2023
1 parent b8e27bd commit ae2513f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/ModernMT.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function translate($source, $target, $q, $hints = null, $context_vector =
$data['format'] = $options['format'];
if (isset($options['alt_translations']))
$data['alt_translations'] = $options['alt_translations'];
if (isset($options['session']))
$data['session'] = $options['session'];
}

return $this->http->send('get', '/translate', $data);
Expand Down Expand Up @@ -125,6 +127,8 @@ public function batchTranslate($webhook, $source, $target, $q, $hints = null, $c
$data['alt_translations'] = $options['alt_translations'];
if (isset($options['metadata']))
$data['metadata'] = $options['metadata'];
if (isset($options['session']))
$data['session'] = $options['session'];

if (isset($options['idempotency_key']))
$headers = ["x-idempotency-key" => $options['idempotency_key']];
Expand Down
10 changes: 6 additions & 4 deletions src/internal/MemoryServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,28 @@ public function delete($id) {
/**
* @throws ModernMTException
*/
public function add($memory, $source, $target, $sentence, $translation, $tuid = null) {
public function add($memory, $source, $target, $sentence, $translation, $tuid = null, $session = null) {
return $this->http->send('post', "/memories/$memory/content", [
'source' => $source,
'target' => $target,
'sentence' => $sentence,
'translation' => $translation,
'tuid' => $tuid
'tuid' => $tuid,
'session' => $session
]);
}

/**
* @throws ModernMTException
*/
public function replace($memory, $tuid, $source, $target, $sentence, $translation) {
public function replace($memory, $tuid, $source, $target, $sentence, $translation, $session = null) {
return $this->http->send('put', "/memories/$memory/content", [
'tuid' => $tuid,
'source' => $source,
'target' => $target,
'sentence' => $sentence,
'translation' => $translation
'translation' => $translation,
'session' => $session
]);
}

Expand Down

0 comments on commit ae2513f

Please sign in to comment.