Skip to content

feat: add updateOption support for source string editing endpoints#260

Open
guptakushal03 wants to merge 2 commits into
crowdin:mainfrom
guptakushal03:feat/source-strings-update-option
Open

feat: add updateOption support for source string editing endpoints#260
guptakushal03 wants to merge 2 commits into
crowdin:mainfrom
guptakushal03:feat/source-strings-update-option

Conversation

@guptakushal03

Copy link
Copy Markdown

Summary

Adds support for the updateOption query parameter to source string editing endpoints.

This change exposes the new Crowdin API functionality for:

  • edit_string
  • string_batch_operation

allowing SDK users to control whether translations and approvals are preserved when updating string text or identifiers.

Changes

  • Added StringUpdateOption enum with supported values:

    • KEEP_TRANSLATIONS_AND_APPROVALS
    • KEEP_TRANSLATIONS
    • CLEAR_TRANSLATIONS_AND_APPROVALS
  • Added optional updateOption parameter to:

    • edit_string
    • string_batch_operation
  • Added unit tests covering both endpoints with and without updateOption.

Testing

Executed the full test suite successfully:

  • 975 tests passed
  • Coverage requirement satisfied

Closes #253

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StringUpdateOption enum for the supported updateOption values.
  • Adds optional updateOption query parameter support to edit_string and string_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"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for updateOption parameter in string editing endpoints

2 participants