feat: add updateOption support for source string editing endpoints#260
Open
guptakushal03 wants to merge 2 commits into
Open
feat: add updateOption support for source string editing endpoints#260guptakushal03 wants to merge 2 commits into
guptakushal03 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds SDK support for Crowdin’s new updateOption query parameter on source string editing endpoints, enabling callers to control whether translations/approvals are preserved when updating string text or identifiers.
Changes:
- Introduces
StringUpdateOptionenum for the supportedupdateOptionvalues. - Adds optional
updateOptionquery parameter support toedit_stringandstring_batch_operation. - Adds unit tests for both endpoints with/without
updateOption.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| crowdin_api/api_resources/source_strings/resource.py | Adds updateOption handling to source string PATCH endpoints (query param). |
| crowdin_api/api_resources/source_strings/enums.py | Defines StringUpdateOption enum values matching API-supported options. |
| crowdin_api/api_resources/source_strings/tests/test_source_strings_resources.py | Adds tests asserting updateOption is sent as a query param for both endpoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
149
to
153
| stringId: int, | ||
| data: Iterable[SourceStringsPatchRequest], | ||
| updateOption: Optional[StringUpdateOption] = None, | ||
| projectId: Optional[int] = None, | ||
| ): |
Comment on lines
180
to
183
| data: Iterable[StringBatchOperationPatchRequest], | ||
| updateOption: Optional[StringUpdateOption] = None, | ||
| projectId: Optional[int] = None, | ||
| ): |
Comment on lines
+167
to
+171
| request_kwargs = { | ||
| "method": "patch", | ||
| "path": self.get_source_strings_path(projectId=projectId, stringId=stringId), | ||
| "request_data": data | ||
| } |
Comment on lines
+206
to
+212
| data = [ | ||
| { | ||
| "value": "test", | ||
| "op": PatchOperation.REPLACE, | ||
| "path": SourceStringsPatchPath.TEXT, | ||
| } | ||
| ] |
| ] | ||
|
|
||
| resource = self.get_resource(base_absolut_url) | ||
| assert resource.edit_string(projectId=1, stringId=2, data=data, updateOption=StringUpdateOption.KEEP_TRANSLATIONS) == "response" |
Comment on lines
+220
to
+222
| params={ | ||
| "updateOption": "keep_translations" | ||
| }, |
Comment on lines
+257
to
+263
| data = [ | ||
| { | ||
| "op": StringBatchOperations.REPLACE, | ||
| "path": StringBatchOperationsPath.IS_HIDDEN, | ||
| "value": True, | ||
| } | ||
| ] |
| ] | ||
|
|
||
| resource = self.get_resource(base_absolut_url) | ||
| assert resource.string_batch_operation(projectId=1, data=data, updateOption=StringUpdateOption.KEEP_TRANSLATIONS) == "response" |
Comment on lines
+271
to
+273
| params={ | ||
| "updateOption": "keep_translations" | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the
updateOptionquery parameter to source string editing endpoints.This change exposes the new Crowdin API functionality for:
edit_stringstring_batch_operationallowing SDK users to control whether translations and approvals are preserved when updating string text or identifiers.
Changes
Added
StringUpdateOptionenum with supported values:KEEP_TRANSLATIONS_AND_APPROVALSKEEP_TRANSLATIONSCLEAR_TRANSLATIONS_AND_APPROVALSAdded optional
updateOptionparameter to:edit_stringstring_batch_operationAdded unit tests covering both endpoints with and without
updateOption.Testing
Executed the full test suite successfully:
Closes #253