Skip to content

Commit

Permalink
Add get_interview_types() in OrganizationSettings entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
koval committed Jul 22, 2024
1 parent 419c165 commit f5f17ab
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
13 changes: 13 additions & 0 deletions huntflow_api_client/entities/organization_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from huntflow_api_client.entities.base import BaseEntity
from huntflow_api_client.models.response.interview_types import InterviewTypesListResponse
from huntflow_api_client.models.response.organization_settings import (
BaseSurveySchemaTypeWithSchemas,
CloseReasonsListResponse,
Expand Down Expand Up @@ -53,3 +54,15 @@ async def get_applicant_survey_form(
f"/accounts/{account_id}/surveys/type_a/{survey_id}",
)
return BaseSurveySchemaTypeWithSchemas.model_validate(response.json())

async def get_interview_types(self, account_id: int) -> InterviewTypesListResponse:
"""
API method reference
https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/interview_types
:param account_id: Organization ID
:return: List of interview types
"""
response = await self._api.request("GET", f"/accounts/{account_id}/interview_types")
return InterviewTypesListResponse.model_validate(response.json())
5 changes: 5 additions & 0 deletions huntflow_api_client/models/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ class UserControlTaskStatus(str, Enum):
PENDING = "PENDING"
SUCCESS = "SUCCESS"
FAILED = "FAILED"


class InterviewType(str, Enum):
USER = "user"
INTERVIEW = "interview"
23 changes: 23 additions & 0 deletions huntflow_api_client/models/response/interview_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field

from huntflow_api_client.models.consts import InterviewType as InterviewTypeEnum


class InterviewType(BaseModel):
id: int = Field(..., description="Interview type ID", examples=[20])
name: str = Field(..., description="Interview type name", examples=["Phone interview"])
account: int = Field(..., description="Organization ID", examples=[42])
removed: Optional[datetime] = Field(None, description="Date and time of removing")
order: int = Field(..., description="Order number")
type: InterviewTypeEnum = Field(
...,
description="Type of the interview",
examples=[InterviewTypeEnum.USER],
)


class InterviewTypesListResponse(BaseModel):
items: list[InterviewType]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[project]
name = "huntflow-api-client"
version = "2.2.0"
version = "2.3.0"
description = "Huntflow API Client for Python"
authors = [
{name = "Developers huntflow", email = "[email protected]"},
Expand Down
28 changes: 28 additions & 0 deletions tests/test_entities/test_organization_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from huntflow_api_client import HuntflowAPI
from huntflow_api_client.entities.organization_settings import OrganizationSettings
from huntflow_api_client.models.response.interview_types import InterviewTypesListResponse
from huntflow_api_client.models.response.organization_settings import (
BaseSurveySchemaTypeWithSchemas,
CloseReasonsListResponse,
Expand All @@ -27,6 +28,18 @@
"schema": {},
"ui_schema": {},
}
INTERVIEW_TYPES_RESPONSE: Dict[str, Any] = {
"items": [
{
"id": 20,
"name": "Phone interview",
"account": 42,
"removed": "2020-01-01T00:00:00+03:00",
"order": 0,
"type": "user",
},
],
}


async def test_get_hold_reasons(
Expand Down Expand Up @@ -72,3 +85,18 @@ async def test_get_applicant_survey_form(

response = await settings.get_applicant_survey_form(ACCOUNT_ID, SURVEY_ID)
assert response == BaseSurveySchemaTypeWithSchemas(**SURVEY_FORM_RESPONSE)


async def test_get_interview_types(
httpx_mock: HTTPXMock,
token_proxy: HuntflowTokenProxy,
) -> None:
httpx_mock.add_response(
url=f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/interview_types",
json=INTERVIEW_TYPES_RESPONSE,
)
api_client = HuntflowAPI(BASE_URL, token_proxy=token_proxy)
settings = OrganizationSettings(api_client)

response = await settings.get_interview_types(ACCOUNT_ID)
assert response == InterviewTypesListResponse(**INTERVIEW_TYPES_RESPONSE)

0 comments on commit f5f17ab

Please sign in to comment.