Skip to content

Commit 5cef058

Browse files
authored
Merge pull request #93 from huntflow/INT-562_create_SurveyTypeA_entity
[INT-562] - create SurveyTypeA entity
2 parents 83dc041 + e36ffe7 commit 5cef058

File tree

9 files changed

+445
-574
lines changed

9 files changed

+445
-574
lines changed

huntflow_api_client/entities/__init__.py

Lines changed: 5 additions & 1 deletion
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
@@ -20,6 +21,7 @@
2021
from huntflow_api_client.entities.regions import Region
2122
from huntflow_api_client.entities.rejection_reason import RejectionReason
2223
from huntflow_api_client.entities.resume import Resume
24+
from huntflow_api_client.entities.survey_type_a import SurveyTypeA
2325
from huntflow_api_client.entities.survey_type_q import SurveyTypeQ
2426
from huntflow_api_client.entities.tags import AccountTag, ApplicantTag
2527
from huntflow_api_client.entities.user_settings import UserSettings
@@ -41,6 +43,7 @@
4143
"ApplicantOffer",
4244
"ApplicantOnVacancy",
4345
"ApplicantOnVacancyStatus",
46+
"ApplicantResponse",
4447
"ApplicantTag",
4548
"ApplicantsQuestionary",
4649
"Coworker",
@@ -54,11 +57,12 @@
5457
"Region",
5558
"RejectionReason",
5659
"Resume",
60+
"SurveyTypeA",
61+
"SurveyTypeQ",
5762
"User",
5863
"UsersManagement",
5964
"UserSettings",
6065
"Vacancy",
6166
"VacancyRequest",
6267
"Webhook",
63-
"SurveyTypeQ",
6468
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from typing import Any, Dict, Optional
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: Optional[str] = None,
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 responses from job sites
25+
"""
26+
path = f"/accounts/{account_id}/applicants/{applicant_id}/responses"
27+
params: Dict[str, Any] = {"count": count}
28+
if next_page_cursor:
29+
params["next_page_cursor"] = next_page_cursor
30+
response = await self._api.request("GET", path, params=params)
31+
return ApplicantResponsesListResponse.model_validate(response.json())
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from huntflow_api_client.entities.base import BaseEntity, GetEntityMixin, ListEntityMixin
2+
from huntflow_api_client.models.response.survey import (
3+
SurveySchemasTypeAListResponse,
4+
SurveySchemaTypeAResponse,
5+
)
6+
7+
8+
class SurveyTypeA(BaseEntity, GetEntityMixin, ListEntityMixin):
9+
async def list(
10+
self,
11+
account_id: int,
12+
active: bool = True,
13+
) -> SurveySchemasTypeAListResponse:
14+
"""
15+
API method reference
16+
https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/surveys/type_a
17+
18+
:param account_id: Organization ID
19+
:param active: Shows only active schemas
20+
:return: List of all applicant feedback forms in organization.
21+
"""
22+
params = {"active": active}
23+
response = await self._api.request(
24+
"GET",
25+
f"/accounts/{account_id}/surveys/type_a",
26+
params=params,
27+
)
28+
return SurveySchemasTypeAListResponse.model_validate(response.json())
29+
30+
async def get(self, account_id: int, survey_id: int) -> SurveySchemaTypeAResponse:
31+
"""
32+
API method reference
33+
https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/surveys/type_a/-survey_id-
34+
35+
:param account_id: Organization ID
36+
:param survey_id: Survey ID
37+
:return: An applicant feedback forms in organization.
38+
"""
39+
response = await self._api.request(
40+
"GET",
41+
f"/accounts/{account_id}/surveys/type_a/{survey_id}",
42+
)
43+
return SurveySchemaTypeAResponse.model_validate(response.json())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
...,
25+
description="Publication of a vacancy for which an applicant responded",
26+
)
27+
28+
29+
class ApplicantResponsesListResponse(BaseModel):
30+
items: List[ApplicantResponse] = Field(..., description="List of applicant's responses")
31+
next_page_cursor: Optional[str] = Field(None, description="Next page cursor")

huntflow_api_client/models/response/survey.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,15 @@ class SurveyQuestionaryAnswerResponse(BaseModel):
6565
respondent: SurveyQuestionaryRespondentWithName
6666
survey_questionary: SurveyQuestionaryCreatedInfo
6767
data: dict = Field(..., description="Answer data")
68+
69+
70+
class SurveySchemasTypeAListResponse(BaseModel):
71+
items: List[BaseSurveySchemaType] = Field(..., description="List of type a survey schemas")
72+
73+
74+
class SurveySchemaTypeAResponse(BaseSurveySchemaTypeWithSchemas):
75+
type: SurveyType = Field(
76+
SurveyType.TYPE_A,
77+
description="Type of survey",
78+
frozen=True,
79+
)

0 commit comments

Comments
 (0)