Skip to content

Commit 91b8f47

Browse files
author
koval
committed
Create ApplicantResponse - draft.
1 parent 40841e8 commit 91b8f47

4 files changed

Lines changed: 116 additions & 0 deletions

File tree

huntflow_api_client/entities/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from huntflow_api_client.entities.applicant_offers import ApplicantOffer
77
from huntflow_api_client.entities.applicant_on_vacancy import ApplicantOnVacancy
88
from huntflow_api_client.entities.applicant_on_vacancy_status import ApplicantOnVacancyStatus
9+
from huntflow_api_client.entities.applicant_reponse import ApplicantResponse
910
from huntflow_api_client.entities.applicants import Applicant
1011
from huntflow_api_client.entities.coworkers import Coworker
1112
from huntflow_api_client.entities.delayed_tasks import DelayedTask
@@ -41,6 +42,7 @@
4142
"ApplicantOffer",
4243
"ApplicantOnVacancy",
4344
"ApplicantOnVacancyStatus",
45+
"ApplicantResponse",
4446
"ApplicantTag",
4547
"ApplicantsQuestionary",
4648
"Coworker",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Any, Dict
2+
3+
from huntflow_api_client.entities.base import BaseEntity, ListEntityMixin
4+
from huntflow_api_client.models.response.applicant_response import ApplicantResponsesListResponse
5+
6+
7+
class ApplicantResponse(BaseEntity, ListEntityMixin):
8+
async def list(
9+
self,
10+
account_id: int,
11+
applicant_id: int,
12+
count: int = 30,
13+
next_page_cursor: int = 1,
14+
) -> ApplicantResponsesListResponse:
15+
"""
16+
API method reference:
17+
https://api.huntflow.ai/v2//docs#get-/accounts/-account_id-/applicants/-applicant_id-/responses
18+
19+
:param account_id: Organization ID
20+
:param applicant_id: Applicant ID
21+
:param count: Number of items per page
22+
:param next_page_cursor: Next page cursor
23+
24+
:return: List of applicant's worklog
25+
"""
26+
path = f"/accounts/{account_id}/applicants/{applicant_id}/responses"
27+
params: Dict[str, Any] = {
28+
"count": count,
29+
"next_page_cursor": next_page_cursor,
30+
}
31+
32+
response = await self._api.request("GET", path, params=params)
33+
return ApplicantResponsesListResponse.model_validate(response.json())
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from datetime import datetime
2+
from typing import List, Optional
3+
4+
from pydantic import BaseModel, Field
5+
6+
7+
class ApplicantResponseVacancy(BaseModel):
8+
id: int = Field(..., description="Vacancy ID")
9+
position: str = Field(..., description="The name of the vacancy (occupation)")
10+
11+
12+
class ApplicantResponseVacancyExternal(BaseModel):
13+
id: int = Field(..., description="Publication ID")
14+
foreign: str = Field(..., description="Foreign publication ID (from job site)")
15+
16+
17+
class ApplicantResponse(BaseModel):
18+
id: int = Field(..., description="Response ID")
19+
foreign: str = Field(..., description="Foreign response ID (from job site)")
20+
created: datetime
21+
applicant_external: int = Field(..., description="Resume ID")
22+
vacancy: ApplicantResponseVacancy = Field(..., description="Vacancy")
23+
vacancy_external: ApplicantResponseVacancyExternal = Field(
24+
..., description="Publication of a vacancy for which an applicant responded"
25+
)
26+
27+
28+
class ApplicantResponsesListResponse(BaseModel):
29+
items: List[ApplicantResponse] = Field(..., description="List of applicant's responses")
30+
next_page_cursor: Optional[str] = Field(None, description="Next page cursor")
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from typing import Any, Dict
2+
3+
from pytest_httpx import HTTPXMock
4+
5+
from huntflow_api_client import HuntflowAPI
6+
from huntflow_api_client.entities import ApplicantResponse
7+
from huntflow_api_client.models.response.applicant_response import ApplicantResponsesListResponse
8+
from huntflow_api_client.tokens.proxy import HuntflowTokenProxy
9+
from tests.api import BASE_URL, VERSIONED_BASE_URL
10+
11+
ACCOUNT_ID = 1
12+
APPLICANT_ID = 2
13+
14+
APPLICANT_RESPONSE_LIST_RESPONSE: Dict[str, Any] = {
15+
"items": [
16+
{
17+
"id": 1,
18+
"foreign": "10",
19+
"created": "2020-01-01T00:00:00+03:00",
20+
"applicant_external": 1,
21+
"vacancy": {
22+
"id": 12,
23+
"position": "Developer",
24+
},
25+
"vacancy_external": {
26+
"id": 10,
27+
"foreign": "10",
28+
},
29+
},
30+
],
31+
"next_page_cursor": "string",
32+
}
33+
34+
35+
async def test_applicant_response_list(
36+
httpx_mock: HTTPXMock,
37+
token_proxy: HuntflowTokenProxy,
38+
) -> None:
39+
httpx_mock.add_response(
40+
url=f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/applicants/{APPLICANT_ID}/responses"
41+
"?count=30&next_page_cursor=1",
42+
status_code=200,
43+
json=APPLICANT_RESPONSE_LIST_RESPONSE,
44+
)
45+
api_client = HuntflowAPI(BASE_URL, token_proxy=token_proxy)
46+
applicant_response = ApplicantResponse(api_client)
47+
48+
response = await applicant_response.list(account_id=ACCOUNT_ID, applicant_id=APPLICANT_ID)
49+
assert response == ApplicantResponsesListResponse.model_validate(
50+
APPLICANT_RESPONSE_LIST_RESPONSE,
51+
)

0 commit comments

Comments
 (0)