Skip to content

Commit ed781f4

Browse files
author
koval
committed
Add new methods.
1 parent 2682919 commit ed781f4

4 files changed

Lines changed: 136 additions & 1 deletion

File tree

huntflow_api_client/entities/user_settings.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from huntflow_api_client.entities.base import BaseEntity
2+
from huntflow_api_client.models.common import StatusResponse
3+
from huntflow_api_client.models.request.user_settings import (
4+
ExchangeEmailAccountRequest,
5+
OtherEmailAccountRequest,
6+
)
27
from huntflow_api_client.models.response.user_settings import (
38
CalendarAccountsListResponse,
9+
EmailAccount,
410
EmailAccountsListResponse,
511
)
612

@@ -23,3 +29,87 @@ async def get_calendar_accounts(self) -> CalendarAccountsListResponse:
2329
"""
2430
response = await self._api.request("GET", "/calendar_accounts")
2531
return CalendarAccountsListResponse.model_validate(response.json())
32+
33+
async def create_exchange_email_account(
34+
self,
35+
data: ExchangeEmailAccountRequest,
36+
) -> EmailAccount:
37+
"""
38+
API method reference https://api.huntflow.ai/v2/docs#post-/email_accounts/exchange
39+
40+
:param data: Exchange user email account data
41+
:return: Created Exchange user email account for API robot.
42+
"""
43+
response = await self._api.request(
44+
"POST",
45+
"/email_accounts/exchange",
46+
json=data.jsonable_dict(exclude_none=True),
47+
)
48+
return EmailAccount.model_validate(response.json())
49+
50+
async def update_exchange_email_account(
51+
self,
52+
data: ExchangeEmailAccountRequest,
53+
account_email_id: int,
54+
) -> EmailAccount:
55+
"""
56+
API method reference
57+
https://api.huntflow.ai/v2/docs#put-/email_accounts/exchange/-account_email_id-
58+
59+
:param account_email_id: Email account ID
60+
:param data: Exchange user email account data
61+
:return: Updated Exchange user email account for API robot.
62+
"""
63+
response = await self._api.request(
64+
"PUT",
65+
f"/email_accounts/exchange/{account_email_id}",
66+
json=data.jsonable_dict(exclude_none=True),
67+
)
68+
return EmailAccount.model_validate(response.json())
69+
70+
async def create_other_email_account(
71+
self,
72+
data: OtherEmailAccountRequest,
73+
) -> EmailAccount:
74+
"""
75+
API method reference https://api.huntflow.ai/v2/docs#post-/email_accounts/other
76+
77+
:param data: SMTP/POP3/IMAP user email account data
78+
:return: Created SMTP/POP3/IMAP user email account for API robot.
79+
"""
80+
response = await self._api.request(
81+
"POST",
82+
"/email_accounts/other",
83+
json=data.jsonable_dict(exclude_none=True),
84+
)
85+
return EmailAccount.model_validate(response.json())
86+
87+
async def update_other_email_account(
88+
self,
89+
data: OtherEmailAccountRequest,
90+
account_email_id: int,
91+
) -> EmailAccount:
92+
"""
93+
API method reference
94+
https://api.huntflow.ai/v2/docs#put-/email_accounts/other/-account_email_id-
95+
96+
:param account_email_id: Email account ID
97+
:param data: SMTP/POP3/IMAP user email account data
98+
:return: Updated SMTP/POP3/IMAP user email account for API robot.
99+
"""
100+
response = await self._api.request(
101+
"PUT",
102+
f"/email_accounts/other/{account_email_id}",
103+
json=data.jsonable_dict(exclude_none=True),
104+
)
105+
return EmailAccount.model_validate(response.json())
106+
107+
async def delete_email_account(self, account_email_id: int) -> StatusResponse:
108+
"""
109+
API method reference
110+
https://api.huntflow.ai/v2/docs#delete-/email_accounts/-account_email_id-
111+
112+
:param account_email_id: Email account ID
113+
"""
114+
response = await self._api.request("DELETE", f"/email_accounts/{account_email_id}")
115+
return StatusResponse.model_validate(response.json())

huntflow_api_client/models/consts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,13 @@ class RecommendationStatus(str, Enum):
196196
class InterviewType(str, Enum):
197197
USER = "user"
198198
INTERVIEW = "interview"
199+
200+
201+
class ExchangeAccessType(str, Enum):
202+
DEFAULT = "DEFAULT"
203+
IMPERSONATION = "IMPERSONATION"
204+
205+
206+
class EmailInboundType(str, Enum):
207+
DEFAULT = "IMAP"
208+
IMPERSONATION = "POP3"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from typing import Optional
2+
3+
from pydantic import AnyHttpUrl, EmailStr, Field, PositiveInt
4+
5+
from huntflow_api_client.models.common import JsonRequestModel
6+
from huntflow_api_client.models.consts import EmailInboundType, ExchangeAccessType
7+
8+
9+
class ExchangeEmailAccountRequest(JsonRequestModel):
10+
"""
11+
Model for EXCHANGE email connection
12+
"""
13+
14+
access_type: ExchangeAccessType = Field(..., description="Exchange access type")
15+
email: EmailStr = Field(..., description="Email address")
16+
ews_url: AnyHttpUrl = Field(..., description="Exchange server URL")
17+
password: str = Field(..., description="Exchange password")
18+
user: Optional[str] = Field(None, description="Exchange user name")
19+
20+
21+
class OtherEmailAccountRequest(JsonRequestModel):
22+
"""
23+
Model for IMAP/POP3 & SMTP email connection
24+
"""
25+
26+
email: EmailStr = Field(..., description="Email address")
27+
password: str = Field(..., description="Mailbox password")
28+
29+
inhost: str = Field(..., description="Inbound mail server URL without protocol")
30+
inport: Optional[PositiveInt] = Field(None, description="Inbound mail port")
31+
in_secure: bool = Field(False, description="Inbound mail server uses SSL")
32+
outhost: str = Field(..., description="Outbound mail server URL without protocol")
33+
outport: Optional[PositiveInt] = Field(None, description="Outbound mail port")
34+
out_secure: bool = Field(False, description="Outbound mail server uses SSL")
35+
type: EmailInboundType = Field(..., description="Type of inbound mail server")

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.7.0"
4+
version = "2.8.0"
55
description = "Huntflow API Client for Python"
66
authors = [
77
{name = "Developers huntflow", email = "developer@huntflow.ru"},

0 commit comments

Comments
 (0)