-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
koval
committed
Mar 28, 2024
1 parent
40841e8
commit 91b8f47
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import Any, Dict | ||
|
||
from huntflow_api_client.entities.base import BaseEntity, ListEntityMixin | ||
from huntflow_api_client.models.response.applicant_response import ApplicantResponsesListResponse | ||
|
||
|
||
class ApplicantResponse(BaseEntity, ListEntityMixin): | ||
async def list( | ||
self, | ||
account_id: int, | ||
applicant_id: int, | ||
count: int = 30, | ||
next_page_cursor: int = 1, | ||
) -> ApplicantResponsesListResponse: | ||
""" | ||
API method reference: | ||
https://api.huntflow.ai/v2//docs#get-/accounts/-account_id-/applicants/-applicant_id-/responses | ||
:param account_id: Organization ID | ||
:param applicant_id: Applicant ID | ||
:param count: Number of items per page | ||
:param next_page_cursor: Next page cursor | ||
:return: List of applicant's worklog | ||
""" | ||
path = f"/accounts/{account_id}/applicants/{applicant_id}/responses" | ||
params: Dict[str, Any] = { | ||
"count": count, | ||
"next_page_cursor": next_page_cursor, | ||
} | ||
|
||
response = await self._api.request("GET", path, params=params) | ||
return ApplicantResponsesListResponse.model_validate(response.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from datetime import datetime | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class ApplicantResponseVacancy(BaseModel): | ||
id: int = Field(..., description="Vacancy ID") | ||
position: str = Field(..., description="The name of the vacancy (occupation)") | ||
|
||
|
||
class ApplicantResponseVacancyExternal(BaseModel): | ||
id: int = Field(..., description="Publication ID") | ||
foreign: str = Field(..., description="Foreign publication ID (from job site)") | ||
|
||
|
||
class ApplicantResponse(BaseModel): | ||
id: int = Field(..., description="Response ID") | ||
foreign: str = Field(..., description="Foreign response ID (from job site)") | ||
created: datetime | ||
applicant_external: int = Field(..., description="Resume ID") | ||
vacancy: ApplicantResponseVacancy = Field(..., description="Vacancy") | ||
vacancy_external: ApplicantResponseVacancyExternal = Field( | ||
..., description="Publication of a vacancy for which an applicant responded" | ||
) | ||
|
||
|
||
class ApplicantResponsesListResponse(BaseModel): | ||
items: List[ApplicantResponse] = Field(..., description="List of applicant's responses") | ||
next_page_cursor: Optional[str] = Field(None, description="Next page cursor") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Any, Dict | ||
|
||
from pytest_httpx import HTTPXMock | ||
|
||
from huntflow_api_client import HuntflowAPI | ||
from huntflow_api_client.entities import ApplicantResponse | ||
from huntflow_api_client.models.response.applicant_response import ApplicantResponsesListResponse | ||
from huntflow_api_client.tokens.proxy import HuntflowTokenProxy | ||
from tests.api import BASE_URL, VERSIONED_BASE_URL | ||
|
||
ACCOUNT_ID = 1 | ||
APPLICANT_ID = 2 | ||
|
||
APPLICANT_RESPONSE_LIST_RESPONSE: Dict[str, Any] = { | ||
"items": [ | ||
{ | ||
"id": 1, | ||
"foreign": "10", | ||
"created": "2020-01-01T00:00:00+03:00", | ||
"applicant_external": 1, | ||
"vacancy": { | ||
"id": 12, | ||
"position": "Developer", | ||
}, | ||
"vacancy_external": { | ||
"id": 10, | ||
"foreign": "10", | ||
}, | ||
}, | ||
], | ||
"next_page_cursor": "string", | ||
} | ||
|
||
|
||
async def test_applicant_response_list( | ||
httpx_mock: HTTPXMock, | ||
token_proxy: HuntflowTokenProxy, | ||
) -> None: | ||
httpx_mock.add_response( | ||
url=f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/applicants/{APPLICANT_ID}/responses" | ||
"?count=30&next_page_cursor=1", | ||
status_code=200, | ||
json=APPLICANT_RESPONSE_LIST_RESPONSE, | ||
) | ||
api_client = HuntflowAPI(BASE_URL, token_proxy=token_proxy) | ||
applicant_response = ApplicantResponse(api_client) | ||
|
||
response = await applicant_response.list(account_id=ACCOUNT_ID, applicant_id=APPLICANT_ID) | ||
assert response == ApplicantResponsesListResponse.model_validate( | ||
APPLICANT_RESPONSE_LIST_RESPONSE, | ||
) |