2017 © Pedro Peláez
 

library smartcat-api

PHP client for SmartCAT API https://smartcat.ai/api/methods/

image

smartcat/smartcat-api

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  • Thursday, May 17, 2018
  • by Diversant_
  • Repository
  • 3 Watchers
  • 1 Stars
  • 451 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 18 Versions
  • 9 % Grown

The README.md

PHP client SmartCAT API

Latest Version Software License Total Downloads, (*1)

PHP client SmartCAT API, (*2)

How to use:

  1. Install composer
  2. composer require smartcat/smartcat-api
  3. composer install, (*3)

    Use Case, (*4)

use SmartCat\Client\SmartCat;

$sc=new SmartCat($login, $password);

Account

Gets the account details
GET /api/integration/v1/account
php $sc->getAccountManager()->accountGetAccountInfo();, (*5)

Gets MT engines available for the account
GET /api/integration/v1/account/mtengines
php $sc->getAccountManager()->accountGetMTEnginesForAccount();, (*6)

Gets LSP's services available for the account](https://smartcat.ai/api/methods/#!/Account/Account_GetLSPServicesForAccount)
GET /api/integration/v1/account/lsp/services
php $sc->getAccountManager()->accountGetLSPServicesForAccount();, (*7)

Gets available assignees (MyTeam freelancers or internal account users)
GET /api/integration/v1/account/assignableExecutives
php $sc->getAccountManager()->accountGetAssignableExecutives();, (*8)

Callback

Reset configurations of notifications reception DELETE /api/integration/v1/callback
php $sc->getCallbackManager()->callbackDelete(), (*9)

Reading configurations of notifications reception of the account GET /api/integration/v1/callback
php $sc->getCallbackManager()->callbackGet(), (*10)

Creating and updating configurations of notifications reception POST /api/integration/v1/callback
php $callback=new CallbackPropertyModel(); $callback->setUrl('https://smartcat.ai'); $res=$sc->getCallbackManager()->callbackUpdate($callback);, (*11)

Reading the last sending errors (no more than 100) GET /api/integration/v1/callback/lastErrors
php $sc->getCallbackManager()->callbackGetLastErrors(['limit'=>$limit]), (*12)

Client

Creates a client with the specified name and returns the Id
If the client already exists, just returns the Id.
POST /api/integration/v1/client/create php $clientId = $sc->getClientManager()->clientCreateClient('Test client');, (*13)

Get details on a client specified within an account
GET /api/integration/v1/client/{clientId} php $client = $sc->getClientManager()->clientGetClient($clientId);, (*14)

Sets the specified net rate model for the specified customer
PUT /api/integration/v1/client/{clientId}/set php $client = $sc->getClientManager()->clientSetClientNetRate($clientId, ['netRateId' => $netRateId]);, (*15)

Directories

Receive the specified directory GET /api/integration/v1/directory
php $sc->getDirectoriesManager()->directoriesGet(['type'=>'projectStatus']), (*16)

Gets parsing formats supported by the account
GET /api/integration/v1/directory/formats
php $sc->getDirectoriesManager()->directoriesGetSupportedFormatsForAccount();, (*17)

Document

Delete one or several documents DELETE /api/integration/v1/document
php $sc->getDocumentManager()->documentDelete(['documentIds'=>['id1','id2']]), (*18)

Receive document model GET /api/integration/v1/document
php $sc->getDocumentManager()->documentGet(['documentId'=>$docId]), (*19)

Update assigned document PUT /api/integration/v1/document/update php $bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all'); $updateDocumentModel = new UploadDocumentPropertiesModel(); $updateDocumentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $res = $sc->getDocumentManager()->documentUpdate([ 'documentId' => $docId, 'updateDocumentModel' => $updateDocumentModel, 'uploadedFile' => [ 'fileContent' => fopen(__DIR__ . '\Resources\File2_EN.docx', 'r'), 'fileName' => 'File2_EN.docx' ] ]);, (*20)

Rename assigned document PUT /api/integration/v1/document/rename php $sc->getDocumentManager()->documentRename(['documentId'=>$docId,'name'=>'New file name']), (*21)

Translate indicated document using the transferred file with translations PUT /api/integration/v1/document/translate
php $sc->getDocumentManager()->documentTranslate([ 'documentId'=>$docId, 'translationFile'=>[ 'filePath'=>'file path', 'fileName'=>'file name' ] ]), (*22)

Импортировать xliff-файл с переводами документа
PUT /api/integration/v1/document/translateWithXliff php $sc->getDocumentManager()->documentTranslateWithXliff([ 'documentId' => $docId, 'confirmTranslation' => true, 'overwriteUpdatedSegments' => true, 'translationFile' => [ 'filePath' => 'file path', 'fileName' => 'file.xliff' ] ]);, (*23)

Receive the status of adding document translation GET /api/integration/v1/document/translate/status php $sc->getDocumentManager()->documentGetTranslationStatus(['documentId'=>$docId]), (*24)

Gets a detailed report about translation importing results
GET /api/integration/v1/document/translate/result php $sc->getDocumentManager()->documentGetTranslationsImportResult(['documentId' => $docsId]);, (*25)

Gets statistics
GET /api/integration/v1/document/statistics php $sc->getDocumentManager()->documentGetStatistics(['documentId' => $docsId]);, (*26)

Split document into equal segments according to the number of words and assign each freelancer to one segment POST /api/integration/v1/document/assignFreelancers
php $sc->getDocumentManager()->documentAssignFreelancersToDocument( ['Abbyyaolid1','Abbyyaolid2'], [ 'documentId' => $documentId, 'stageNumber' => $stageNumber ] ), (*27)

DocumentExport

Request document (-s) export POST /api/integration/v1/document/export
php $sc->getDocumentExportManager()->documentExportRequestExport(['documentIds'=>['documenId1','documentId2']), (*28)

Download the results of export GET /api/integration/v1/document/export/{taskId}
php $sc->getDocumentExportManager()->documentExportDownloadExportResult($taskId);, (*29)

Glossary

Получить набор глоссариев
GET /api/integration/v1/glossaries
php $res = $sc->getGlossaryManager()->glossaryGetGlossaries();, (*30)

Invoice

Creates a payable for a freelancer
POST /api/integration/v1/invoice/job php $importJobModel = new ImportJobModel(); $importJobModel->setFreelancerId($freelanceId) ->setServiceType('translation') ->setJobDescription('Test invoice') ->setUnitsType('Any text') ->setUnitsAmount(10) ->setPricePerUnit(1) ->setCurrency('usd'); $res=$sc->getInvoiceManager()->invoiceImportJob($importJobModel);, (*31)

PlaceholderFormatApi

Gets all placeholder formats available in the current account
GET /api/integration/v1/placeholders
php $res = $sc->getPlaceholderFormatApiManager()->placeholderFormatApiGetPlaceholderFormats();, (*32)

Saves a set of placeholder formats for the current account
PUT /api/integration/v1/placeholders
php $placeHolder1 = new PlaceholderFormatModel(); $placeHolder1->setRegex($regEx1); $placeHolder2 = new PlaceholderFormatModel(); $placeHolder2->setRegex($regEx2); $res = $sc->getPlaceholderFormatApiManager()->placeholderFormatApiUpdatePlaceholderFormats([$placeHolder1, $placeHolder2]);, (*33)

Validates the specified placeholder format
GET /api/integration/v1/placeholders/validate
php $res = $this->sc->getPlaceholderFormatApiManager()->placeholderFormatApiValidatePlaceholderFormat(['format' => 'Stable\:(\s+)(.+)[\r|]\n']);, (*34)

Project

Delete project DELETE /api/integration/v1/project/{projectId} php $sc->getProjectManager()->projectDelete($projectId), (*35)

Receive project model GET /api/integration/v1/project/{projectId} php sc->getProjectManager()->projectGet($projectId), (*36)

Update project using ID
PUT /api/integration/v1/project/{projectId}, (*37)

Receive the list of all projects in account GET /api/integration/v1/project/list php $sc->getProjectManager()->projectGetAll(), (*38)

Receive statistics and project value
GET /api/integration/v2/project/{projectId}/statistics
php $sc->getProjectManager()->projectGetProjectStatistics($projectId); do { sleep(5); $res = $sc->getProjectManager()->projectGetProjectStatistics($projectId); } while(!is_array($res));, (*39)

Receiving statistics for the completed parts of the project
GET /api/integration/v1/project/{projectId}/completedWorkStatistics
php $res = $sc->getProjectManager()->projectGetCompletedWorkStatistics($projectId);, (*40)

Receiving a list of the TMs plugged into the project
GET /api/integration/v1/project/{projectId}/translationmemories
php $res = $sc->getProjectManager()->projectGetProjectTranslationMemories($projectId);, (*41)

Rewrite connected TMs — same set of TMs for all target languages
POST /api/integration/v1/project/{projectId}/translationmemories
php $translationMemoryForProjectModel = new TranslationMemoryForProjectModel(); $translationMemoryForProjectModel->setId($tmId); $translationMemoryForProjectModel->setIsWritable(true); $translationMemoryForProjectModel->setMatchThreshold(100); $res = $sc->getProjectManager()->projectSetTranslationMemoriesForWholeProject($projectId, [$translationMemoryForProjectModel]);, (*42)

Gets a set of glossaries enabled for a project
GET /api/integration/v1/project/{projectId}/glossaries
php $res = $sc->getProjectManager()->projectGetGlossaries($projectId);, (*43)

Enables a set of glossaries for a project
PUT /api/integration/v1/project/{projectId}/glossaries
php $res = $this->sc->getProjectManager()->projectSetGlossaries($projectId, [$glossaryId1, $glossaryId2]);, (*44)

Starts generating statistics for the project
POST /api/integration/v1/project/{projectId}/statistics/build
php $sc->getProjectManager()->projectBuildStatistics($this->prj->getId());, (*45)

Rewrite connected TMs — each target language with its own set of TMs
POST /api/integration/v1/project/{projectId}/translationmemories/bylanguages
php $translationMemoryForProjectModel = new TranslationMemoryForProjectModel(); $translationMemoryForProjectModel->setId($tmId); $translationMemoryForProjectModel->setIsWritable(true); $translationMemoryForProjectModel->setMatchThreshold(100); $tm = new TranslationMemoriesForLanguageModel(); $tm->setLanguage('en'); $tm->setTranslationMemories([$translationMemoryForProjectModel]); $res = $sc->getProjectManager()->projectSetProjectTranslationMemoriesByLanguages($projectId, [$tm]);, (*46)

Create a project POST /api/integration/v1/project/create
php $prjCreate = new CreateProjectWithFilesModel(); $prjCreate->setName('Test project'); $prjCreate->setDescription('Test project'); $prjCreate->setSourceLanguage('ru'); $prjCreate->setTargetLanguages(['en']); $prjCreate->setAssignToVendor(false); $prjCreate->setUseMT(false); $prjCreate->setPretranslate(false); $prjCreate->setAutoPropagateRepetitions(false); $prjCreate->setIsForTesting(true); $prjCreate->setWorkflowStages(['translation']); $prjCreate->attacheFile(fopen(__DIR__.'\Resources\File1_EN.docx'),'File1_EN.docx'); $sc->getProjectManager()->projectCreateProjectWithFiles($prjCreate);, (*47)

Add new document to project POST /api/integration/v1/project/document
php $bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all'); $documentModel = new CreateDocumentPropertyWithFilesModel(); $documentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $documentModel->attachFile(fopen(__DIR__ . '\Resources\File2_EN.docx'), 'File2_EN.docx'); $res = $sc->getProjectManager()->projectAddDocument([ 'documentModel' => [$documentModel], 'projectId' => $projectId ]); If you want to set Disassemble Settings, you should set Disassemble Algorithm. For example: ```php $bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all');, (*48)

$disassembleSettings = (new DisassembleSettingsModel()) ->setTranslatableAttributes(['img'=>['data-caption']]);, (*49)

$documentModel = new CreateDocumentPropertyWithFilesModel(); $documentModel->setDisassembleAlgorithmName('html'); $documentModel->setDisassembleSettings($disassembleSettings); $documentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $documentModel->attachFile(fopen(DIR . '\Resources\File2_EN.docx'), 'File2_EN.docx'); $res = $sc->getProjectManager()->projectAddDocument([ 'documentModel' => [$documentModel], 'projectId' => $projectId ]); ```, (*50)

Deprecated: php $sc->getProjectManager()->projectAddDocument([ 'projectId'=>$projectId, 'file' => [ 'filePath'=>'path to file', 'fileName'=>'File name' ] ]);, (*51)

Add new target language to project POST /api/integration/v1/project/language
php $sc->getProjectManager()->projectAddLanguage(['projectId'=>$projectId,'targetLanguage'=>'ja']);, (*52)

Assign the group of translators for the specific stage of documents in project PUT /api/integration/v1/project/{projectId}/assignGroupToWorkflowStage
php $sc->getProjectManager()->projectAssignGroupToWorkflowStage($projectId,['groupName'=>'Administrators','workflowStage'=>'translation']), (*53)

Cancel project POST /api/integration/v1/project/cancel php $sc->getProjectManager()->projectCancelProject(['projectId'=>$projectId]), (*54)

Restore project POST /api/integration/v1/project/restore
php $sc->getProjectManager()->projectRestoreProject(['projectId'=>$projectId]), (*55)

Completes the workflow for all project documents. The project status will change to Completed.
POST /api/integration/v1/project/restore
php $sc->getProjectManager()->projectCompleteProject(['projectId' => $this->prj->getId()]);, (*56)

TranslationMemories

Deletes the TM
DELETE /api/integration/v1/translationmemory/{tmId}
php $sc->getTranslationMemoriesManager()->translationMemoriesRemoveTranslationMemory($tmId), (*57)

Gets TM details
GET /api/integration/v1/translationmemory/{tmId}
php $sc->getTranslationMemoriesManager()->translationMemoriesGetMetaInfo($tmId);, (*58)

Imports TMX files into the TM
POST /api/integration/v1/translationmemory/{tmId}
php $sc->getTranslationMemoriesManager()->translationMemoriesImport( $tmId, [ 'replaceAllContent' => 'true', 'tmxFile' => [ 'filePath' => __DIR__ . '\Resources\Space.tmx' ] ] );, (*59)

Gets a collection of TMs available for the account
GET /api/integration/v1/translationmemory
php $thirstRes = $sc->getTranslationMemoriesManager()->translationMemoriesGetTranslationMemoriesBatch([ 'lastProcessedId' => '', 'batchSize' => 10 ]); $last = array_pop($thirstRes); $secondRes = $sc->getTranslationMemoriesManager()->translationMemoriesGetTranslationMemoriesBatch([ 'lastProcessedId' => $last->getId(), 'batchSize' => $count ]);, (*60)

Creates an empty TM
POST /api/integration/v1/translationmemory
```php $tm = new CreateTranslationMemoryModel(); $name = 'PHP Unit ' . date('U'); $tm->setName($name); $tm->setSourceLanguage('ru'); $tm->setTargetLanguages(['en']); $tm->setDescription("Description: $name");, (*61)

$tmId = $sc->getTranslationMemoriesManager()->translationMemoriesCreateEmptyTM($tm); ```, (*62)

Gets a collection of tasks for TMX import
GET /api/integration/v1/translationmemory/task
php $sc->getTranslationMemoriesManager()->translationMemoriesGetPendingTasks();, (*63)

Sets an array of target languages required by the TM
PUT /api/integration/v1/translationmemory/{tmId}/target
php $sc->getTranslationMemoriesManager()->translationMemoriesSetTMTargetLanguages($tmId, ["en", "es"]);, (*64)

Exports TMX files from the TM
GET /api/integration/v1/translationmemory/{tmId}/file
php $sc->getTranslationMemoriesManager()->translationMemoriesExportFile($tmId, ['withTags' => true]), (*65)

Gets matches from a given TM
POST /api/integration/v1/translationmemory/matches
```php $tmMatch = new TmMatchesRequest(); $tmMatch->setSourceLanguage('en'); $tmMatch->setTargetLanguage('ru'); $segmentModel = new SegmentModel(); $segmentModel->setText('Test text message'); $segmentModel->setPrevContext(''); $segmentModel->setNextContext(''); $segmentModel->setTags([]); $tmMatch->setSegmentModel($segmentModel);, (*66)

$sc->getTranslationMemoriesManager()->translationMemoriesGetTMTranslations($tmMatch, ['tmId' => $tmId]); ```, (*67)

Removes a given import task
DELETE /api/integration/v1/translationmemory/task/{taskId}
php $sc->getTranslationMemoriesManager()->translationMemoriesRemoveSpecificImportTask($last->getId()), (*68)

User

Creates a new user with the specified parameters
POST /api/integration/v1/user
php $user = new CreateUserRequest(); $user->setEmail('test@test.com') ->setFirstName('FirstName') ->setLastName('LastName') ->setExternalId('my-external-id') ->setRightsGroup('executive'); $res = $sc->getUserManager()->userCreate($user);, (*69)

Deletes a user
DELETE /api/integration/v1/user/{accountUserId} php $sc->getUserManager()->userDelete($smartcatAccountUserId);, (*70)

Gets a user model
GET /api/integration/v1/user/{accountUserId} php $res = $sc->getUserManager()->userGet($smartcatAccountUserId);, (*71)

Updates user data
PUT /api/integration/v1/user/{accountUserId} php $updateModel = new UpdateUserRequest(); $updateModel->setFirstName($newName); $sc->getUserManager()->userUpdate($smartcatAccountUserId, $updateModel);, (*72)

Gets a user by its external ID
GET /api/integration/v1/user/external
php $res = $sc->getUserManager()->userGetExternal(['id' => $externalId]);, (*73)

The Versions

17/05 2018

dev-master

9999999-dev https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

13/09 2017

1.7.0

1.7.0.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

07/09 2017

1.6.0

1.6.0.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

09/08 2017

1.5.2

1.5.2.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

15/05 2017

1.5.1

1.5.1.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

12/05 2017

1.5.0

1.5.0.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

10/03 2017

1.4.0

1.4.0.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

20/01 2017

1.3.1

1.3.1.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

20/01 2017
09/01 2017
23/12 2016
23/12 2016
15/12 2016
09/12 2016
05/12 2016
07/11 2016

1.0.2

1.0.2.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

11/10 2016

1.0.1

1.0.1.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat

13/09 2016

1.0.0

1.0.0.0 https://github.com/smartcatai/SmartCAT-API

PHP client for SmartCAT API https://smartcat.ai/api/methods/

  Sources   Download

GPL v3

The Requires

 

The Development Requires

by Andrey Rybnikov

api php smartcat