Skip to content

Commit 5803a76

Browse files
author
koval
committed
Add WebhookType.
1 parent 3d399b3 commit 5803a76

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

huntflow_api_client/entities/webhooks.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1+
from typing import Optional
2+
13
from huntflow_api_client.entities.base import (
24
BaseEntity,
35
CreateEntityMixin,
46
DeleteEntityMixin,
57
ListEntityMixin,
68
)
9+
from huntflow_api_client.models.consts import WebhookType
710
from huntflow_api_client.models.request.webhooks import WebhookRequest
811
from huntflow_api_client.models.response.webhooks import WebhookResponse, WebhooksListResponse
912

1013

1114
class Webhook(BaseEntity, ListEntityMixin, CreateEntityMixin, DeleteEntityMixin):
12-
async def list(self, account_id: int) -> WebhooksListResponse:
15+
async def list(
16+
self,
17+
account_id: int,
18+
webhook_type: Optional[WebhookType] = None,
19+
) -> WebhooksListResponse:
1320
"""
1421
API method reference https://api.huntflow.ai/v2/docs#get-/accounts/-account_id-/hooks
1522
1623
:param account_id: Organization ID
24+
:param webhook_type: Webhook type. If no value provided, webhooks of all types will be
25+
returned.
1726
:return: List of webhooks
1827
"""
1928
path = f"/accounts/{account_id}/hooks"
20-
response = await self._api.request("GET", path)
29+
params = {}
30+
if webhook_type:
31+
params["webhook_type"] = webhook_type.value
32+
response = await self._api.request("GET", path, params=params)
2133
return WebhooksListResponse.model_validate(response.json())
2234

2335
async def create(self, account_id: int, data: WebhookRequest) -> WebhookResponse:

huntflow_api_client/models/consts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class WebhookEvent(str, Enum):
1111
SURVEY_QUESTIONARY = "SURVEY-QUESTIONARY"
1212

1313

14+
class WebhookType(str, Enum):
15+
USER = "USER"
16+
APPLICATION = "APPLICATION"
17+
18+
1419
class MemberType(str, Enum):
1520
owner = "owner"
1621
manager = "manager"

huntflow_api_client/models/request/webhooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from pydantic import Field
44

55
from huntflow_api_client.models.common import JsonRequestModel
6-
from huntflow_api_client.models.consts import WebhookEvent
6+
from huntflow_api_client.models.consts import WebhookEvent, WebhookType
77

88

99
class WebhookRequest(JsonRequestModel):
1010
secret: str = Field(..., description="Secret key")
1111
url: str = Field(..., description="Webhook URL")
1212
active: bool = Field(..., description="Webhook activity flag")
1313
webhook_events: List[WebhookEvent] = Field(..., description="List of webhook events")
14+
type: WebhookType = Field(default=WebhookType.USER, description="Webhook type")

huntflow_api_client/models/response/webhooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pydantic import AnyHttpUrl, BaseModel, Field, PositiveInt
55

6-
from huntflow_api_client.models.consts import WebhookEvent
6+
from huntflow_api_client.models.consts import WebhookEvent, WebhookType
77

88

99
class WebhookResponse(BaseModel):
@@ -13,6 +13,7 @@ class WebhookResponse(BaseModel):
1313
created: datetime = Field(..., description="Date and time of creating a webhook")
1414
active: bool = Field(..., description="Webhook activity flag")
1515
webhook_events: List[WebhookEvent] = Field(..., description="List of webhook events")
16+
type: WebhookType = Field(..., description="Webhook type")
1617

1718

1819
class WebhooksListResponse(BaseModel):

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.4.0"
4+
version = "2.5.0"
55
description = "Huntflow API Client for Python"
66
authors = [
77
{name = "Developers huntflow", email = "[email protected]"},

0 commit comments

Comments
 (0)