11from 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+ )
27from 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 ())
0 commit comments