Skip to content

Commit

Permalink
Merge pull request #93 from huntflow/INT-562_create_SurveyTypeA_entity
Browse files Browse the repository at this point in the history
[INT-562] - create SurveyTypeA entity
  • Loading branch information
polina-koval authored May 3, 2024
2 parents 83dc041 + e36ffe7 commit 5cef058
Show file tree
Hide file tree
Showing 9 changed files with 445 additions and 574 deletions.
6 changes: 5 additions & 1 deletion huntflow_api_client/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from huntflow_api_client.entities.applicant_offers import ApplicantOffer
from huntflow_api_client.entities.applicant_on_vacancy import ApplicantOnVacancy
from huntflow_api_client.entities.applicant_on_vacancy_status import ApplicantOnVacancyStatus
from huntflow_api_client.entities.applicant_reponse import ApplicantResponse
from huntflow_api_client.entities.applicants import Applicant
from huntflow_api_client.entities.coworkers import Coworker
from huntflow_api_client.entities.delayed_tasks import DelayedTask
Expand All @@ -20,6 +21,7 @@
from huntflow_api_client.entities.regions import Region
from huntflow_api_client.entities.rejection_reason import RejectionReason
from huntflow_api_client.entities.resume import Resume
from huntflow_api_client.entities.survey_type_a import SurveyTypeA
from huntflow_api_client.entities.survey_type_q import SurveyTypeQ
from huntflow_api_client.entities.tags import AccountTag, ApplicantTag
from huntflow_api_client.entities.user_settings import UserSettings
Expand All @@ -41,6 +43,7 @@
"ApplicantOffer",
"ApplicantOnVacancy",
"ApplicantOnVacancyStatus",
"ApplicantResponse",
"ApplicantTag",
"ApplicantsQuestionary",
"Coworker",
Expand All @@ -54,11 +57,12 @@
"Region",
"RejectionReason",
"Resume",
"SurveyTypeA",
"SurveyTypeQ",
"User",
"UsersManagement",
"UserSettings",
"Vacancy",
"VacancyRequest",
"Webhook",
"SurveyTypeQ",
)
31 changes: 31 additions & 0 deletions huntflow_api_client/entities/applicant_reponse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import Any, Dict, Optional

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: Optional[str] = None,
) -> 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 responses from job sites
"""
path = f"/accounts/{account_id}/applicants/{applicant_id}/responses"
params: Dict[str, Any] = {"count": count}
if next_page_cursor:
params["next_page_cursor"] = next_page_cursor
response = await self._api.request("GET", path, params=params)
return ApplicantResponsesListResponse.model_validate(response.json())
43 changes: 43 additions & 0 deletions huntflow_api_client/entities/survey_type_a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from huntflow_api_client.entities.base import BaseEntity, GetEntityMixin, ListEntityMixin
from huntflow_api_client.models.response.survey import (
SurveySchemasTypeAListResponse,
SurveySchemaTypeAResponse,
)


class SurveyTypeA(BaseEntity, GetEntityMixin, ListEntityMixin):
async def list(
self,
account_id: int,
active: bool = True,
) -> SurveySchemasTypeAListResponse:
"""
API method reference
https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/surveys/type_a
:param account_id: Organization ID
:param active: Shows only active schemas
:return: List of all applicant feedback forms in organization.
"""
params = {"active": active}
response = await self._api.request(
"GET",
f"/accounts/{account_id}/surveys/type_a",
params=params,
)
return SurveySchemasTypeAListResponse.model_validate(response.json())

async def get(self, account_id: int, survey_id: int) -> SurveySchemaTypeAResponse:
"""
API method reference
https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/surveys/type_a/-survey_id-
:param account_id: Organization ID
:param survey_id: Survey ID
:return: An applicant feedback forms in organization.
"""
response = await self._api.request(
"GET",
f"/accounts/{account_id}/surveys/type_a/{survey_id}",
)
return SurveySchemaTypeAResponse.model_validate(response.json())
31 changes: 31 additions & 0 deletions huntflow_api_client/models/response/applicant_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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")
12 changes: 12 additions & 0 deletions huntflow_api_client/models/response/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ class SurveyQuestionaryAnswerResponse(BaseModel):
respondent: SurveyQuestionaryRespondentWithName
survey_questionary: SurveyQuestionaryCreatedInfo
data: dict = Field(..., description="Answer data")


class SurveySchemasTypeAListResponse(BaseModel):
items: List[BaseSurveySchemaType] = Field(..., description="List of type a survey schemas")


class SurveySchemaTypeAResponse(BaseSurveySchemaTypeWithSchemas):
type: SurveyType = Field(
SurveyType.TYPE_A,
description="Type of survey",
frozen=True,
)
Loading

0 comments on commit 5cef058

Please sign in to comment.