diff --git a/src/CrowdinApiClient/Api/TranslationMemoryApi.php b/src/CrowdinApiClient/Api/TranslationMemoryApi.php index 85f3cffb..6a6bfd96 100644 --- a/src/CrowdinApiClient/Api/TranslationMemoryApi.php +++ b/src/CrowdinApiClient/Api/TranslationMemoryApi.php @@ -187,4 +187,25 @@ public function checkImportStatus(int $translationMemoryId, string $importId): ? $path = sprintf('tms/%d/imports/%s', $translationMemoryId, $importId); return $this->_get($path, TranslationMemoryImport::class); } + + + /** + * Concordance Search in TMs + * @link https://support.crowdin.com/developer/api/v2/#tag/Translation-Memory/operation/api.projects.tms.concordance.post API Documentation + * @link https://support.crowdin.com/developer/enterprise/api/v2/#tag/Translation-Memory/operation/api.projects.tms.concordance.post API Documentation Enterprise + * + * @param int $projectId + * @param array $params + * string $params[sourceLanguageId]
+ * integer $params[targetLanguageId]
+ * boolean $params[autoSubstitution]
+ * integer $params[minRelevant]: 40-100
+ * [string] $params[expressions] + * @return TranslationMemory + */ + public function concordanceSearchTM(int $projectId, array $params = []): ?TranslationMemory + { + $path = sprintf('projects/%d/tms/concordance', $projectId); + return $this->_post($path, TranslationMemory::class, $params); + } } diff --git a/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php b/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php index 3e6778ff..3ccda4cb 100644 --- a/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php +++ b/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php @@ -303,4 +303,49 @@ public function testClear() $this->mockRequestDelete('/tms/4/segments'); $this->crowdin->translationMemory->clear(4); } + + + public function testConcordanceSearch() + { + $params = [ + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'ru', + 'autoSubstitution' => true, + 'minRelevant' => 50, + 'expressions' => ['Welcome!'] + ]; + + $this->mockRequest([ + 'path' => '/projects/4/tms/concordance', + 'method' => 'post', + 'body' => json_encode($params), + 'response' => '{ + "data": [ + { + "data": { + "tm": { + "id": 4, + "name": "Knowledge Base\'s TM" + }, + "recordId": 34, + "source": "Welcome!", + "target": "Ласкаво просимо!", + "relevant": 100, + "substituted": "62→100", + "updatedAt": "2022-09-28T12:29:34+00:00" + } + } + ], + "pagination": [ + { + "offset": 0, + "limit": 25 + } + ] + }' + ]); + + $export = $this->crowdin->translationMemory->concordanceSearchTM(4, $params); + $this->assertInstanceOf(TranslationMemory::class, $export); + } }