Skip to content

Commit d0dc8d3

Browse files
authored
Merge pull request #107 from huntflow/DEV-21405_add_pd_endpoints
[DEV-21405] - Add pd endpoints
2 parents 510abe6 + e97a878 commit d0dc8d3

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

huntflow_api_client/entities/applicants.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
ApplicantUpdateRequest,
1313
)
1414
from huntflow_api_client.models.response.applicants import (
15+
ApplicantCreateAgreementLinkResponse,
1516
ApplicantCreateResponse,
1617
ApplicantItem,
1718
ApplicantListResponse,
1819
ApplicantSearchByCursorResponse,
20+
ApplicantSendAgreementResponse,
1921
)
2022

2123

@@ -186,3 +188,41 @@ async def search_by_cursor(
186188

187189
response = await self._api.request("GET", path, params=params)
188190
return ApplicantSearchByCursorResponse.model_validate(response.json())
191+
192+
async def create_agreement_link(
193+
self,
194+
account_id: int,
195+
applicant_id: int,
196+
) -> ApplicantCreateAgreementLinkResponse:
197+
"""
198+
API method reference:
199+
https://api.huntflow.ai/v2/docs#post-/accounts/-account_id-/applicants/-applicant_id-/agreement_link
200+
201+
:param account_id: Organization ID
202+
:param applicant_id: Applicant ID
203+
:return: Link to interact with agreement
204+
"""
205+
response = await self._api.request(
206+
"POST",
207+
f"/accounts/{account_id}/applicants/{applicant_id}/agreement_link",
208+
)
209+
return ApplicantCreateAgreementLinkResponse.model_validate(response.json())
210+
211+
async def send_agreement_via_email(
212+
self,
213+
account_id: int,
214+
applicant_id: int,
215+
) -> ApplicantSendAgreementResponse:
216+
"""
217+
API method reference:
218+
https://api.huntflow.ai/v2/docs#post-/accounts/-account_id-/applicants/-applicant_id-/agreement_email
219+
220+
:param account_id: Organization ID
221+
:param applicant_id: Applicant ID
222+
:return: Job_id and recipient email of agreement
223+
"""
224+
response = await self._api.request(
225+
"POST",
226+
f"/accounts/{account_id}/applicants/{applicant_id}/agreement_email",
227+
)
228+
return ApplicantSendAgreementResponse.model_validate(response.json())

huntflow_api_client/models/response/applicants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,12 @@ class ApplicantSearchItem(BaseModel):
133133
class ApplicantSearchByCursorResponse(BaseModel):
134134
items: List[ApplicantSearchItem] = Field(..., description="List of applicants")
135135
next_page_cursor: Optional[str] = Field(None, description="Next page cursor")
136+
137+
138+
class ApplicantCreateAgreementLinkResponse(BaseModel):
139+
link: str = Field(..., description="Link to agreement")
140+
141+
142+
class ApplicantSendAgreementResponse(BaseModel):
143+
sent_to: str = Field(..., description="Email recipient")
144+
job_id: str = Field(..., description="Job ID")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[project]
33
name = "huntflow-api-client"
4-
version = "2.8.0"
4+
version = "2.9.0"
55
description = "Huntflow API Client for Python"
66
authors = [
77
{name = "Developers huntflow", email = "[email protected]"},

tests/test_entities/test_applicants.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
ApplicantUpdateRequest,
1010
)
1111
from huntflow_api_client.models.response.applicants import (
12+
ApplicantCreateAgreementLinkResponse,
1213
ApplicantCreateResponse,
1314
ApplicantItem,
1415
ApplicantListResponse,
1516
ApplicantSearchByCursorResponse,
17+
ApplicantSendAgreementResponse,
1618
)
1719
from huntflow_api_client.tokens.proxy import HuntflowTokenProxy
1820
from tests.api import BASE_URL, VERSIONED_BASE_URL
@@ -269,6 +271,12 @@
269271
"next_page_cursor": "3VudCI6IjoXIjogW10IiwgMy4wXX0=",
270272
}
271273

274+
APPLICANT_CREATE_AGREEMENT_RESPONSE: Dict[str, Any] = {"link": "https://agreement.example/1"}
275+
APPLICANT_SEND_AGREEMENT_RESPONSE: Dict[str, Any] = {
276+
"sent_to": "[email protected]",
277+
"job_id": "job-id-1111",
278+
}
279+
272280

273281
async def test_list_applicant(
274282
httpx_mock: HTTPXMock,
@@ -385,3 +393,35 @@ async def test_applicant_search_by_cursor(
385393
assert response == ApplicantSearchByCursorResponse.model_validate(
386394
APPLICANT_SEARCH_BY_CURSOR_RESPONSE,
387395
)
396+
397+
398+
async def test_create_agreement_link(
399+
httpx_mock: HTTPXMock,
400+
token_proxy: HuntflowTokenProxy,
401+
) -> None:
402+
httpx_mock.add_response(
403+
url=f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/applicants/{APPLICANT_ID}/agreement_link",
404+
json=APPLICANT_CREATE_AGREEMENT_RESPONSE,
405+
)
406+
api_client = HuntflowAPI(BASE_URL, token_proxy=token_proxy)
407+
408+
applicants = Applicant(api_client)
409+
410+
response = await applicants.create_agreement_link(ACCOUNT_ID, APPLICANT_ID)
411+
assert response == ApplicantCreateAgreementLinkResponse(**APPLICANT_CREATE_AGREEMENT_RESPONSE)
412+
413+
414+
async def test_send_agreement_via_email(
415+
httpx_mock: HTTPXMock,
416+
token_proxy: HuntflowTokenProxy,
417+
) -> None:
418+
httpx_mock.add_response(
419+
url=f"{VERSIONED_BASE_URL}/accounts/{ACCOUNT_ID}/applicants/{APPLICANT_ID}/agreement_email",
420+
json=APPLICANT_SEND_AGREEMENT_RESPONSE,
421+
)
422+
api_client = HuntflowAPI(BASE_URL, token_proxy=token_proxy)
423+
424+
applicants = Applicant(api_client)
425+
426+
response = await applicants.send_agreement_via_email(ACCOUNT_ID, APPLICANT_ID)
427+
assert response == ApplicantSendAgreementResponse(**APPLICANT_SEND_AGREEMENT_RESPONSE)

0 commit comments

Comments
 (0)