diff --git a/huntflow_api_client/entities/vacancy_requests.py b/huntflow_api_client/entities/vacancy_requests.py index f818946..debbe84 100644 --- a/huntflow_api_client/entities/vacancy_requests.py +++ b/huntflow_api_client/entities/vacancy_requests.py @@ -21,6 +21,8 @@ async def list( count: int = 30, page: int = 1, values: bool = False, + include_taken: bool = False, + include_not_approved: bool = False, ) -> VacancyRequestListResponse: """ API method reference: @@ -32,8 +34,18 @@ async def list( :param count: Number of items per page :param page: Page number :param values: Show values flag. If True, vacancy requests fields will be included + :param include_taken: Show requests already taken to work. + If True,requests taken to work shown + :param include_not_approved: Show vacancy requests from other coworkers. + If True, requests from other coworkers shown + :raises ValueError: + Parameters include_taken/include_not_approved cannot be passed with vacancy_id :return: List of vacancy requests """ + if vacancy_id and (include_taken or include_not_approved): + raise ValueError( + "Parameters include_taken/include_not_approved cannot be passed with vacancy_id", + ) path = f"/accounts/{account_id}/vacancy_requests" params = { "count": count, @@ -42,6 +54,9 @@ async def list( } if vacancy_id: params["vacancy_id"] = vacancy_id + else: + params["include_taken"] = include_taken + params["include_not_approved"] = include_not_approved response = await self._api.request("GET", path, params=params) return VacancyRequestListResponse.model_validate(response.json()) diff --git a/pyproject.toml b/pyproject.toml index ef5a8a9..27f0b0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "huntflow-api-client" -version = "2.13.7" +version = "2.13.8" description = "Huntflow API Client for Python" authors = [ {name = "Developers huntflow", email = "developer@huntflow.ru"}, diff --git a/tests/test_entities/test_vacancy_request.py b/tests/test_entities/test_vacancy_request.py index b096365..9cb0630 100644 --- a/tests/test_entities/test_vacancy_request.py +++ b/tests/test_entities/test_vacancy_request.py @@ -1,3 +1,4 @@ +import pytest from pytest_httpx import HTTPXMock from huntflow_api_client import HuntflowAPI @@ -85,6 +86,7 @@ async def test_list_vacancy_request( url=( f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}" f"/vacancy_requests?page=1&&count=30&&values=false" + f"&&include_taken=false&&include_not_approved=false" ), json=VACANCY_REQUEST_LIST_WITHOUT_VALUES, ) @@ -107,6 +109,56 @@ async def test_list_vacancy_request( response = await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, values=True) assert response == VacancyRequestListResponse.model_validate(VACANCY_REQUEST_LIST_WITH_VALUES) + httpx_mock.add_response( + url=( + f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?" + f"page=1&&count=30&&values=false&&include_taken=false&&include_not_approved=true" + ), + json=VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + response = await vacancy_request.list(ACCOUNT_ID, include_not_approved=True) + assert response == VacancyRequestListResponse.model_validate( + VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + + httpx_mock.add_response( + url=( + f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?" + f"page=1&&count=30&&values=false&&include_taken=true&&include_not_approved=false" + ), + json=VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + response = await vacancy_request.list(ACCOUNT_ID, include_taken=True) + assert response == VacancyRequestListResponse.model_validate( + VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + + httpx_mock.add_response( + url=( + f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/vacancy_requests?" + f"page=1&&count=30&&values=false&&include_taken=true&&include_not_approved=true" + ), + json=VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + response = await vacancy_request.list(ACCOUNT_ID, include_taken=True, include_not_approved=True) + assert response == VacancyRequestListResponse.model_validate( + VACANCY_REQUEST_LIST_WITHOUT_VALUES, + ) + + with pytest.raises(ValueError): + await vacancy_request.list( + ACCOUNT_ID, + vacancy_id=1, + include_taken=True, + include_not_approved=True, + ) + + with pytest.raises(ValueError): + await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, include_taken=True) + + with pytest.raises(ValueError): + await vacancy_request.list(ACCOUNT_ID, vacancy_id=1, include_not_approved=True) + async def test_get_vacancy_request( httpx_mock: HTTPXMock,