Skip to content

Commit

Permalink
feat(string_translations): Remove String Approvals (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmAximani0 authored Oct 10, 2024
1 parent 5f0a3ce commit 87e0122
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
21 changes: 20 additions & 1 deletion crowdin_api/api_resources/string_translations/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def add_approval(
request_data={"translationId": translationId},
)

def remove_string_approvals(self, stringId: int, projectId: Optional[int] = None):
"""
Remove String Approvals
Link to documentaion:
https://support.crowdin.com/developer/api/v2/#tag/String-Translations/operation/api.projects.approvals.deleteMany
"""

projectId = projectId or self.get_project_id()

params = {"stringId": stringId}

return self.requester.request(
method="delete", path=self.get_approvals_path(projectId=projectId), params=params
)

def get_approval(self, approvalId: int, projectId: Optional[int] = None):
"""
Get Approval.
Expand Down Expand Up @@ -248,7 +264,10 @@ def add_translation(
)

def delete_string_translations(
self, stringId: int, languageId: str, projectId: Optional[int] = None
self,
stringId: int,
languageId: Optional[str] = None,
projectId: Optional[int] = None,
):
"""
Delete String Translations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ def test_add_approval(self, m_request, base_absolut_url):
request_data={"translationId": 2},
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_remove_string_approvals(self, m_request, base_absolut_url):
m_request.return_value = "response"

stringId = 1
projectId = 2
resource = self.get_resource(base_absolut_url)
assert (
resource.remove_string_approvals(stringId=stringId, projectId=projectId)
== "response"
)
m_request.assert_called_once_with(
method="delete",
path=resource.get_approvals_path(projectId=projectId),
params={"stringId": stringId},
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_get_approval(self, m_request, base_absolut_url):
m_request.return_value = "response"
Expand Down

0 comments on commit 87e0122

Please sign in to comment.