diff --git a/crowdin_api/api_resources/translations/resource.py b/crowdin_api/api_resources/translations/resource.py index cefe2e3..a81fa1c 100644 --- a/crowdin_api/api_resources/translations/resource.py +++ b/crowdin_api/api_resources/translations/resource.py @@ -172,6 +172,25 @@ def edit_pre_translation( request_data=data, ) + def pre_translation_batch_operations( + self, + data: Iterable[EditPreTranslationScheme], + projectId: Optional[int] = None, + ): + """ + Pre-Translation Batch Operations. + + Link to documentation: + https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.pre-translations.patchBatch + """ + projectId = projectId or self.get_project_id() + + return self.requester.request( + method="patch", + path=f"projects/{projectId}/pre-translations", + request_data=data, + ) + def build_project_directory_translation( self, directoryId: int, diff --git a/crowdin_api/api_resources/translations/tests/test_translations_resources.py b/crowdin_api/api_resources/translations/tests/test_translations_resources.py index faa83ca..4b7af7f 100644 --- a/crowdin_api/api_resources/translations/tests/test_translations_resources.py +++ b/crowdin_api/api_resources/translations/tests/test_translations_resources.py @@ -277,6 +277,31 @@ def test_edit_bundle(self, m_request, base_absolut_url): request_data=data, ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_pre_translation_batch_operations(self, m_request, base_absolut_url): + m_request.return_value = "response" + + data = [ + { + "op": PreTranslationEditOperation.REPLACE, + "path": "/9e7de270-4f83-41cb-b606-2f90631f26e2/status", + "value": "canceled", + }, + { + "op": PreTranslationEditOperation.REPLACE, + "path": "/9e7de270-4f83-41cb-b606-2f90631f26e2/priority", + "value": "high", + }, + ] + + resource = self.get_resource(base_absolut_url) + assert resource.pre_translation_batch_operations(projectId=1, data=data) == "response" + m_request.assert_called_once_with( + method="patch", + path="projects/1/pre-translations", + request_data=data, + ) + @pytest.mark.parametrize( "in_params, request_data, headers", (