Skip to content

Commit 16ce5de

Browse files
authored
feat(screenshots): added params and deprecation warning (#173)
1 parent 2f94be4 commit 16ce5de

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

crowdin_api/api_resources/screenshots/resource.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Iterable, Optional
22

3+
import warnings
34
from crowdin_api.api_resources.abstract.resources import BaseResource
45
from crowdin_api.api_resources.screenshots.types import (
56
AddTagRequest,
@@ -30,8 +31,10 @@ def get_screenshots_path(self, projectId: int, screenshotId: Optional[int] = Non
3031

3132
def list_screenshots(
3233
self,
34+
orderBy: Optional[str] = None,
3335
projectId: Optional[int] = None,
3436
stringId: Optional[int] = None,
37+
stringIds: Optional[Iterable[int]] = None,
3538
labelIds: Optional[Iterable[int]] = None,
3639
excludeLabelIds: Optional[Iterable[int]] = None,
3740
page: Optional[int] = None,
@@ -47,7 +50,11 @@ def list_screenshots(
4750

4851
projectId = projectId or self.get_project_id()
4952

50-
params = {"stringId": stringId, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds}
53+
if stringId:
54+
warnings.warn("`stringId` is deprecated, use `stringIds` instead", category=DeprecationWarning)
55+
stringIds = [stringId]
56+
57+
params = {"orderBy": orderBy, "stringIds": stringIds, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds}
5158
params.update(self.get_page_params(page=page, offset=offset, limit=limit))
5259

5360
return self._get_entire_data(

crowdin_api/api_resources/screenshots/tests/test_screenshots_resources.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,21 @@ def test_get_screenshots_path(self, in_params, path, base_absolut_url):
3636
def test_list_screenshots(self, m_request, base_absolut_url):
3737
m_request.return_value = "response"
3838
resource = self.get_resource(base_absolut_url)
39-
assert resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10}) == "response"
39+
assert (
40+
resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10})
41+
== "response"
42+
)
4043
m_request.assert_called_once_with(
4144
method="get",
4245
path=resource.get_screenshots_path(projectId=1),
43-
params={'stringId': None, 'labelIds': None, 'excludeLabelIds': None, 'offset': 0, 'limit': 10},
46+
params={
47+
"orderBy": None,
48+
"stringIds": None,
49+
"labelIds": None,
50+
"excludeLabelIds": None,
51+
"offset": 0,
52+
"limit": 10,
53+
},
4454
)
4555

4656
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)