-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser_settings.py
More file actions
115 lines (100 loc) · 4.16 KB
/
user_settings.py
File metadata and controls
115 lines (100 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from huntflow_api_client.entities.base import BaseEntity
from huntflow_api_client.models.common import StatusResponse
from huntflow_api_client.models.request.user_settings import (
ExchangeEmailAccountRequest,
OtherEmailAccountRequest,
)
from huntflow_api_client.models.response.user_settings import (
CalendarAccountsListResponse,
EmailAccount,
EmailAccountsListResponse,
)
class UserSettings(BaseEntity):
async def get_email_accounts(self) -> EmailAccountsListResponse:
"""
API method reference https://api.huntflow.ai/v2/docs#get-/email_accounts
:return: List of user email accounts.
"""
response = await self._api.request("GET", "/email_accounts")
return EmailAccountsListResponse.model_validate(response.json())
async def get_calendar_accounts(self) -> CalendarAccountsListResponse:
"""
API method reference https://api.huntflow.ai/v2/docs#get-/calendar_accounts
:return: List of user calendar accounts with associated calendars.
"""
response = await self._api.request("GET", "/calendar_accounts")
return CalendarAccountsListResponse.model_validate(response.json())
async def create_exchange_email_account(
self,
data: ExchangeEmailAccountRequest,
) -> EmailAccount:
"""
API method reference https://api.huntflow.ai/v2/docs#post-/email_accounts/exchange
:param data: Exchange user email account data
:return: Created Exchange user email account for API robot.
"""
response = await self._api.request(
"POST",
"/email_accounts/exchange",
json=data.jsonable_dict(exclude_none=True),
)
return EmailAccount.model_validate(response.json())
async def update_exchange_email_account(
self,
data: ExchangeEmailAccountRequest,
account_email_id: int,
) -> EmailAccount:
"""
API method reference
https://api.huntflow.ai/v2/docs#put-/email_accounts/exchange/-account_email_id-
:param account_email_id: Email account ID
:param data: Exchange user email account data
:return: Updated Exchange user email account for API robot.
"""
response = await self._api.request(
"PUT",
f"/email_accounts/exchange/{account_email_id}",
json=data.jsonable_dict(exclude_none=True),
)
return EmailAccount.model_validate(response.json())
async def create_other_email_account(
self,
data: OtherEmailAccountRequest,
) -> EmailAccount:
"""
API method reference https://api.huntflow.ai/v2/docs#post-/email_accounts/other
:param data: SMTP/POP3/IMAP user email account data
:return: Created SMTP/POP3/IMAP user email account for API robot.
"""
response = await self._api.request(
"POST",
"/email_accounts/other",
json=data.jsonable_dict(exclude_none=True),
)
return EmailAccount.model_validate(response.json())
async def update_other_email_account(
self,
data: OtherEmailAccountRequest,
account_email_id: int,
) -> EmailAccount:
"""
API method reference
https://api.huntflow.ai/v2/docs#put-/email_accounts/other/-account_email_id-
:param account_email_id: Email account ID
:param data: SMTP/POP3/IMAP user email account data
:return: Updated SMTP/POP3/IMAP user email account for API robot.
"""
response = await self._api.request(
"PUT",
f"/email_accounts/other/{account_email_id}",
json=data.jsonable_dict(exclude_none=True),
)
return EmailAccount.model_validate(response.json())
async def delete_email_account(self, account_email_id: int) -> StatusResponse:
"""
API method reference
https://api.huntflow.ai/v2/docs#delete-/email_accounts/-account_email_id-
:param account_email_id: Email account ID
"""
response = await self._api.request("DELETE", f"/email_accounts/{account_email_id}")
return StatusResponse.model_validate(response.json())