diff --git a/crowdin_api/api_resources/users/resource.py b/crowdin_api/api_resources/users/resource.py index 23f870a..7f6302e 100644 --- a/crowdin_api/api_resources/users/resource.py +++ b/crowdin_api/api_resources/users/resource.py @@ -31,9 +31,6 @@ def list_project_members( Link to documentation: https://developer.crowdin.com/api/v2/#operation/api.projects.members.getMany - - Link to documentation for enterprise: - https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.members.getMany """ projectId = projectId or self.get_project_id() @@ -90,6 +87,33 @@ def get_users_path(self, userId: Optional[int] = None): return "users" + def list_project_members( + self, + projectId: Optional[int] = None, + search: Optional[str] = None, + workflowStepId: Optional[int] = None, + languageId: Optional[str] = None, + page: Optional[int] = None, + offset: Optional[int] = None, + limit: Optional[int] = None, + ): + """ + List Project Members. + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.members.getMany + """ + + projectId = projectId or self.get_project_id() + params = {"search": search, "workflowStepId": workflowStepId, "languageId": languageId} + params.update(self.get_page_params(page=page, offset=offset, limit=limit)) + + return self._get_entire_data( + method="get", + path=self.get_members_path(projectId=projectId), + params=params, + ) + def add_project_member( self, userIds: Iterable[int], diff --git a/crowdin_api/api_resources/users/tests/test_users_resources.py b/crowdin_api/api_resources/users/tests/test_users_resources.py index 0ae619d..ff271bb 100644 --- a/crowdin_api/api_resources/users/tests/test_users_resources.py +++ b/crowdin_api/api_resources/users/tests/test_users_resources.py @@ -153,6 +153,47 @@ def test_get_users_path(self, userId, path, base_absolut_url): resource = self.get_resource(base_absolut_url) assert resource.get_users_path(userId=userId) == path + @pytest.mark.parametrize( + "in_params, request_params", + ( + ( + {}, + { + "search": None, + "workflowStepId": None, + "languageId": None, + "offset": 0, + "limit": 25, + }, + ), + ( + { + "search": "search", + "workflowStepId": 72, + "languageId": "ua", + "offset": 0, + "limit": 25, + }, + { + "search": "search", + "workflowStepId": 72, + "languageId": "ua", + "offset": 0, + "limit": 25, + }, + ), + ), + ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_list_project_members(self, m_request, in_params, request_params, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.list_project_members(projectId=1, **in_params) == "response" + m_request.assert_called_once_with( + method="get", params=request_params, path="projects/1/members" + ) + @pytest.mark.parametrize( "in_params, request_params", (