From b5f61dd537f646c88258121e9127c8a52de363a0 Mon Sep 17 00:00:00 2001 From: pjcodes404 Date: Mon, 1 Dec 2025 14:37:51 +0530 Subject: [PATCH 1/2] feat(string-comments): add attachments support and delete attachment endpoint --- .../api_resources/string_comments/resource.py | 19 +++++++++++++++++++ .../tests/test_string_comments_resources.py | 14 ++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/crowdin_api/api_resources/string_comments/resource.py b/crowdin_api/api_resources/string_comments/resource.py index 7d00fb6..46ec5ef 100644 --- a/crowdin_api/api_resources/string_comments/resource.py +++ b/crowdin_api/api_resources/string_comments/resource.py @@ -69,6 +69,7 @@ def add_string_comment( type: StringCommentType, projectId: Optional[int] = None, issueType: Optional[StringCommentIssueType] = None, + attachments: Optional[Iterable[int]] = None, ): """ Add String Comment. @@ -88,6 +89,7 @@ def add_string_comment( "targetLanguageId": targetLanguageId, "type": type, "issueType": issueType, + "attachments": attachments, }, ) @@ -127,6 +129,23 @@ def delete_string_comment( ), ) + def delete_string_comment_attachment( + self, stringCommentId: int, attachmentId: int, projectId: Optional[int] = None + ): + """ + Delete String Comment Attachment. + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.comments.attachments.delete + """ + + projectId = projectId or self.get_project_id() + + return self.requester.request( + method="delete", + path=f"{self.get_string_comments_path(projectId=projectId, stringCommentId=stringCommentId)}/attachments/{attachmentId}", + ) + def edit_string_comment( self, stringCommentId: int, diff --git a/crowdin_api/api_resources/string_comments/tests/test_string_comments_resources.py b/crowdin_api/api_resources/string_comments/tests/test_string_comments_resources.py index e024403..20f3e7a 100644 --- a/crowdin_api/api_resources/string_comments/tests/test_string_comments_resources.py +++ b/crowdin_api/api_resources/string_comments/tests/test_string_comments_resources.py @@ -110,6 +110,7 @@ def test_list_string_comments(self, m_request, in_params, request_params, base_a "targetLanguageId": "ua", "type": StringCommentType.COMMENT, "issueType": None, + "attachments": None, }, ), ( @@ -119,6 +120,7 @@ def test_list_string_comments(self, m_request, in_params, request_params, base_a "targetLanguageId": "ua", "type": StringCommentType.COMMENT, "issueType": StringCommentIssueType.CONTEXT_REQUEST, + "attachments": [1, 2, 3], }, { "text": "text", @@ -126,6 +128,7 @@ def test_list_string_comments(self, m_request, in_params, request_params, base_a "targetLanguageId": "ua", "type": StringCommentType.COMMENT, "issueType": StringCommentIssueType.CONTEXT_REQUEST, + "attachments": [1, 2, 3], }, ), ), @@ -142,6 +145,17 @@ def test_add_string_comment(self, m_request, in_params, request_data, base_absol request_data=request_data, ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_delete_string_comment_attachment(self, m_request, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.delete_string_comment_attachment(projectId=1, stringCommentId=2, attachmentId=3) == "response" + m_request.assert_called_once_with( + method="delete", + path=resource.get_string_comments_path(projectId=1, stringCommentId=2) + "/attachments/3", + ) + @mock.patch("crowdin_api.requester.APIRequester.request") def test_get_string_comment(self, m_request, base_absolut_url): m_request.return_value = "response" From ae61c6e045155502aaf2539c7a93840c796c3f37 Mon Sep 17 00:00:00 2001 From: pjcodes404 Date: Mon, 1 Dec 2025 16:59:33 +0530 Subject: [PATCH 2/2] style: fix flake8 long line --- crowdin_api/api_resources/string_comments/resource.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crowdin_api/api_resources/string_comments/resource.py b/crowdin_api/api_resources/string_comments/resource.py index 46ec5ef..f5a702e 100644 --- a/crowdin_api/api_resources/string_comments/resource.py +++ b/crowdin_api/api_resources/string_comments/resource.py @@ -143,7 +143,10 @@ def delete_string_comment_attachment( return self.requester.request( method="delete", - path=f"{self.get_string_comments_path(projectId=projectId, stringCommentId=stringCommentId)}/attachments/{attachmentId}", + path=( + f"{self.get_string_comments_path(projectId=projectId, stringCommentId=stringCommentId)}" + f"/attachments/{attachmentId}" + ), ) def edit_string_comment(