diff --git a/crowdin_api/api_resources/string_comments/resource.py b/crowdin_api/api_resources/string_comments/resource.py index 7d00fb6..f5a702e 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,26 @@ 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)}" + f"/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"