Skip to content

Commit 87e0122

Browse files
authored
feat(string_translations): Remove String Approvals (#177)
1 parent 5f0a3ce commit 87e0122

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

crowdin_api/api_resources/string_translations/resource.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ def add_approval(
7979
request_data={"translationId": translationId},
8080
)
8181

82+
def remove_string_approvals(self, stringId: int, projectId: Optional[int] = None):
83+
"""
84+
Remove String Approvals
85+
86+
Link to documentaion:
87+
https://support.crowdin.com/developer/api/v2/#tag/String-Translations/operation/api.projects.approvals.deleteMany
88+
"""
89+
90+
projectId = projectId or self.get_project_id()
91+
92+
params = {"stringId": stringId}
93+
94+
return self.requester.request(
95+
method="delete", path=self.get_approvals_path(projectId=projectId), params=params
96+
)
97+
8298
def get_approval(self, approvalId: int, projectId: Optional[int] = None):
8399
"""
84100
Get Approval.
@@ -248,7 +264,10 @@ def add_translation(
248264
)
249265

250266
def delete_string_translations(
251-
self, stringId: int, languageId: str, projectId: Optional[int] = None
267+
self,
268+
stringId: int,
269+
languageId: Optional[str] = None,
270+
projectId: Optional[int] = None,
252271
):
253272
"""
254273
Delete String Translations.

crowdin_api/api_resources/string_translations/tests/test_string_translations_resources.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ def test_add_approval(self, m_request, base_absolut_url):
9898
request_data={"translationId": 2},
9999
)
100100

101+
@mock.patch("crowdin_api.requester.APIRequester.request")
102+
def test_remove_string_approvals(self, m_request, base_absolut_url):
103+
m_request.return_value = "response"
104+
105+
stringId = 1
106+
projectId = 2
107+
resource = self.get_resource(base_absolut_url)
108+
assert (
109+
resource.remove_string_approvals(stringId=stringId, projectId=projectId)
110+
== "response"
111+
)
112+
m_request.assert_called_once_with(
113+
method="delete",
114+
path=resource.get_approvals_path(projectId=projectId),
115+
params={"stringId": stringId},
116+
)
117+
101118
@mock.patch("crowdin_api.requester.APIRequester.request")
102119
def test_get_approval(self, m_request, base_absolut_url):
103120
m_request.return_value = "response"

0 commit comments

Comments
 (0)