From 683824ddf454267893a377f56b2f79fba12055c6 Mon Sep 17 00:00:00 2001 From: OmAxiani0 <75031769+OmAximani0@users.noreply.github.com> Date: Wed, 2 Oct 2024 00:28:21 +0530 Subject: [PATCH] feat(screenshots): added params and deprecation warning Signed-off-by: OmAxiani0 <75031769+OmAximani0@users.noreply.github.com> --- crowdin_api/api_resources/screenshots/resource.py | 9 ++++++++- .../tests/test_screenshots_resources.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crowdin_api/api_resources/screenshots/resource.py b/crowdin_api/api_resources/screenshots/resource.py index 005d226..62dcb70 100644 --- a/crowdin_api/api_resources/screenshots/resource.py +++ b/crowdin_api/api_resources/screenshots/resource.py @@ -1,5 +1,6 @@ from typing import Iterable, Optional +import warnings from crowdin_api.api_resources.abstract.resources import BaseResource from crowdin_api.api_resources.screenshots.types import ( AddTagRequest, @@ -30,8 +31,10 @@ def get_screenshots_path(self, projectId: int, screenshotId: Optional[int] = Non def list_screenshots( self, + orderBy: Optional[str] = None, projectId: Optional[int] = None, stringId: Optional[int] = None, + stringIds: Optional[Iterable[int]] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, page: Optional[int] = None, @@ -47,7 +50,11 @@ def list_screenshots( projectId = projectId or self.get_project_id() - params = {"stringId": stringId, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds} + if stringId: + warnings.warn("`stringId` is deprecated, use `stringIds` instead", category=DeprecationWarning) + stringIds = [stringId] + + params = {"orderBy": orderBy, "stringIds": stringIds, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds} params.update(self.get_page_params(page=page, offset=offset, limit=limit)) return self._get_entire_data( diff --git a/crowdin_api/api_resources/screenshots/tests/test_screenshots_resources.py b/crowdin_api/api_resources/screenshots/tests/test_screenshots_resources.py index d64b7b1..3202f03 100644 --- a/crowdin_api/api_resources/screenshots/tests/test_screenshots_resources.py +++ b/crowdin_api/api_resources/screenshots/tests/test_screenshots_resources.py @@ -36,11 +36,21 @@ def test_get_screenshots_path(self, in_params, path, base_absolut_url): def test_list_screenshots(self, m_request, base_absolut_url): m_request.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10}) == "response" + assert ( + resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10}) + == "response" + ) m_request.assert_called_once_with( method="get", path=resource.get_screenshots_path(projectId=1), - params={'stringId': None, 'labelIds': None, 'excludeLabelIds': None, 'offset': 0, 'limit': 10}, + params={ + "orderBy": None, + "stringIds": None, + "labelIds": None, + "excludeLabelIds": None, + "offset": 0, + "limit": 10, + }, ) @pytest.mark.parametrize(