aircall-api 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aircall/__init__.py +38 -0
- aircall/client.py +273 -0
- aircall/exceptions.py +55 -0
- aircall/logging_config.py +81 -0
- aircall/models/__init__.py +83 -0
- aircall/models/ai_voice_agent.py +49 -0
- aircall/models/call.py +94 -0
- aircall/models/company.py +14 -0
- aircall/models/contact.py +32 -0
- aircall/models/content.py +42 -0
- aircall/models/conversation_intelligence.py +66 -0
- aircall/models/dialer_campaign.py +21 -0
- aircall/models/integration.py +20 -0
- aircall/models/ivr_option.py +22 -0
- aircall/models/message.py +52 -0
- aircall/models/number.py +55 -0
- aircall/models/participant.py +38 -0
- aircall/models/tag.py +18 -0
- aircall/models/team.py +20 -0
- aircall/models/user.py +48 -0
- aircall/models/webhook.py +22 -0
- aircall/resources/__init__.py +29 -0
- aircall/resources/base.py +77 -0
- aircall/resources/call.py +270 -0
- aircall/resources/company.py +29 -0
- aircall/resources/contact.py +192 -0
- aircall/resources/dialer_campaign.py +90 -0
- aircall/resources/integration.py +53 -0
- aircall/resources/message.py +80 -0
- aircall/resources/number.py +94 -0
- aircall/resources/tag.py +83 -0
- aircall/resources/team.py +92 -0
- aircall/resources/user.py +129 -0
- aircall/resources/webhook.py +82 -0
- aircall_api-1.1.0.dist-info/METADATA +429 -0
- aircall_api-1.1.0.dist-info/RECORD +39 -0
- aircall_api-1.1.0.dist-info/WHEEL +5 -0
- aircall_api-1.1.0.dist-info/licenses/LICENSE +21 -0
- aircall_api-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Resource module for managing messages"""
|
|
2
|
+
from aircall.resources.base import BaseResource
|
|
3
|
+
from aircall.models import Message
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MessageResource(BaseResource):
|
|
7
|
+
"""
|
|
8
|
+
API Resource for Aircall Messages.
|
|
9
|
+
|
|
10
|
+
Handles SMS, MMS, and WhatsApp messaging operations.
|
|
11
|
+
All operations are scoped to a specific number.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def create_configuration(self, number_id: int, **kwargs) -> dict:
|
|
15
|
+
"""
|
|
16
|
+
Create message configuration for a number.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
number_id: The ID of the number
|
|
20
|
+
**kwargs: Configuration data
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
dict: Configuration response
|
|
24
|
+
"""
|
|
25
|
+
return self._post(f"/numbers/{number_id}/messages/configuration", json=kwargs)
|
|
26
|
+
|
|
27
|
+
def get_configuration(self, number_id: int) -> dict:
|
|
28
|
+
"""
|
|
29
|
+
Fetch message configuration for a number.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
number_id: The ID of the number
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
dict: Configuration data
|
|
36
|
+
"""
|
|
37
|
+
return self._get(f"/numbers/{number_id}/messages/configuration")
|
|
38
|
+
|
|
39
|
+
def delete_configuration(self, number_id: int) -> dict:
|
|
40
|
+
"""
|
|
41
|
+
Delete message configuration for a number.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
number_id: The ID of the number
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
dict: Delete configuration response
|
|
48
|
+
"""
|
|
49
|
+
return self._delete(f"/numbers/{number_id}/messages/configuration")
|
|
50
|
+
|
|
51
|
+
def send(self, number_id: int, to: str, body: str, **kwargs) -> Message:
|
|
52
|
+
"""
|
|
53
|
+
Send a message from a number.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
number_id: The ID of the number to send from
|
|
57
|
+
to: Recipient phone number
|
|
58
|
+
body: Message body
|
|
59
|
+
**kwargs: Additional message data (media_details, etc.)
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
Message: The sent message object
|
|
63
|
+
"""
|
|
64
|
+
data = {"to": to, "body": body, **kwargs}
|
|
65
|
+
response = self._post(f"/numbers/{number_id}/messages/send", json=data)
|
|
66
|
+
return Message(**response["message"])
|
|
67
|
+
|
|
68
|
+
def send_native(self, number_id: int, **kwargs) -> Message:
|
|
69
|
+
"""
|
|
70
|
+
Send a native message (WhatsApp template) from a number.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
number_id: The ID of the number to send from
|
|
74
|
+
**kwargs: Native message data (template_id, parameters, etc.)
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
Message: The sent message object
|
|
78
|
+
"""
|
|
79
|
+
response = self._post(f"/numbers/{number_id}/messages/native/send", json=kwargs)
|
|
80
|
+
return Message(**response["message"])
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Number resource for managing Aircall phone numbers."""
|
|
2
|
+
|
|
3
|
+
from aircall.resources.base import BaseResource
|
|
4
|
+
from aircall.models import Number
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NumberResource(BaseResource):
|
|
8
|
+
"""
|
|
9
|
+
API resource for Aircall phone numbers.
|
|
10
|
+
|
|
11
|
+
Handles operations related to phone numbers including listing,
|
|
12
|
+
retrieving, updating, and checking registration status.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def list_numbers(self, page: int = 1, per_page: int = 20) -> list[Number]:
|
|
16
|
+
"""
|
|
17
|
+
List all numbers with pagination.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
page: Page number (default 1)
|
|
21
|
+
per_page: Results per page (default 20, max 50)
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
list[Number]: List of Number objects
|
|
25
|
+
|
|
26
|
+
Note:
|
|
27
|
+
Response includes pagination metadata in 'meta' field:
|
|
28
|
+
- count: Items in current page
|
|
29
|
+
- total: Total items
|
|
30
|
+
- current_page: Current page number
|
|
31
|
+
- next_page_link: URL to next page (if available)
|
|
32
|
+
- previous_page_link: URL to previous page (if available)
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
>>> numbers = client.number.list_numbers(page=1, per_page=50)
|
|
36
|
+
>>> for number in numbers:
|
|
37
|
+
... print(number.name, number.digits)
|
|
38
|
+
"""
|
|
39
|
+
response = self._get("/numbers", params={"page": page, "per_page": per_page})
|
|
40
|
+
return [Number(**n) for n in response["numbers"]]
|
|
41
|
+
|
|
42
|
+
def get(self, number_id: int) -> Number:
|
|
43
|
+
"""
|
|
44
|
+
Retrieve a specific number by ID.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
number_id: Unique identifier for the number
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Number: Number object
|
|
51
|
+
|
|
52
|
+
Raises:
|
|
53
|
+
Exception: If number not found (404) or other API error
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
>>> number = client.number.get(12345)
|
|
57
|
+
>>> print(number.name, number.digits)
|
|
58
|
+
"""
|
|
59
|
+
response = self._get(f"/numbers/{number_id}")
|
|
60
|
+
return Number(**response["number"])
|
|
61
|
+
|
|
62
|
+
def update(self, number_id: int, **kwargs) -> Number:
|
|
63
|
+
"""
|
|
64
|
+
Update a number's configuration.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
number_id: Unique identifier for the number
|
|
68
|
+
**kwargs: Fields to update (e.g., name, priority)
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Number: Updated Number object
|
|
72
|
+
|
|
73
|
+
Example:
|
|
74
|
+
>>> number = client.number.update(12345, name="Sales Line", priority=1)
|
|
75
|
+
>>> print(number.name) # "Sales Line"
|
|
76
|
+
"""
|
|
77
|
+
response = self._put(f"/numbers/{number_id}", json=kwargs)
|
|
78
|
+
return Number(**response["number"])
|
|
79
|
+
|
|
80
|
+
def get_registration_status(self, number_id: int) -> dict:
|
|
81
|
+
"""
|
|
82
|
+
Get registration status for a number.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
number_id: Unique identifier for the number
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
dict: Registration status information
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
>>> status = client.number.get_registration_status(12345)
|
|
92
|
+
>>> print(status)
|
|
93
|
+
"""
|
|
94
|
+
return self._get(f"/numbers/{number_id}/registration_status")
|
aircall/resources/tag.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Resource module for managing tags"""
|
|
2
|
+
from aircall.resources.base import BaseResource
|
|
3
|
+
from aircall.models import Tag
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TagResource(BaseResource):
|
|
7
|
+
"""
|
|
8
|
+
API Resource for Aircall Tags.
|
|
9
|
+
|
|
10
|
+
Tags are used to categorize calls and can be created by Admins.
|
|
11
|
+
Note: Emojis cannot be used in tag attributes and will be removed.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def list_tags(self, page: int = 1, per_page: int = 20) -> list[Tag]:
|
|
15
|
+
"""
|
|
16
|
+
List all tags with pagination.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
page: Page number (default 1)
|
|
20
|
+
per_page: Results per page (default 20, max 50)
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
list[Tag]: List of Tag objects
|
|
24
|
+
"""
|
|
25
|
+
response = self._get("/tags", params={"page": page, "per_page": per_page})
|
|
26
|
+
return [Tag(**t) for t in response["tags"]]
|
|
27
|
+
|
|
28
|
+
def get(self, tag_id: int) -> Tag:
|
|
29
|
+
"""
|
|
30
|
+
Get a specific tag by ID.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
tag_id: The ID of the tag to retrieve
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Tag: The tag object
|
|
37
|
+
"""
|
|
38
|
+
response = self._get(f"/tags/{tag_id}")
|
|
39
|
+
return Tag(**response["tag"])
|
|
40
|
+
|
|
41
|
+
def create(self, name: str, color: str, description: str = None) -> Tag:
|
|
42
|
+
"""
|
|
43
|
+
Create a new tag.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
name: Tag name (emojis will be removed)
|
|
47
|
+
color: Tag color in hexadecimal format (e.g., "#FF5733")
|
|
48
|
+
description: Optional tag description
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Tag: The created tag object
|
|
52
|
+
"""
|
|
53
|
+
data = {"name": name, "color": color}
|
|
54
|
+
if description:
|
|
55
|
+
data["description"] = description
|
|
56
|
+
response = self._post("/tags", json=data)
|
|
57
|
+
return Tag(**response["tag"])
|
|
58
|
+
|
|
59
|
+
def update(self, tag_id: int, **kwargs) -> Tag:
|
|
60
|
+
"""
|
|
61
|
+
Update a tag.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
tag_id: The ID of the tag to update
|
|
65
|
+
**kwargs: Tag fields to update (name, color, description)
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Tag: The updated tag object
|
|
69
|
+
"""
|
|
70
|
+
response = self._put(f"/tags/{tag_id}", json=kwargs)
|
|
71
|
+
return Tag(**response["tag"])
|
|
72
|
+
|
|
73
|
+
def delete(self, tag_id: int) -> dict:
|
|
74
|
+
"""
|
|
75
|
+
Delete a tag.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
tag_id: The ID of the tag to delete
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
dict: Delete response
|
|
82
|
+
"""
|
|
83
|
+
return self._delete(f"/tags/{tag_id}")
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Resource module for managing teams"""
|
|
2
|
+
from aircall.resources.base import BaseResource
|
|
3
|
+
from aircall.models import Team
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TeamResource(BaseResource):
|
|
7
|
+
"""
|
|
8
|
+
API Resource for Aircall Teams.
|
|
9
|
+
|
|
10
|
+
Teams are used to group users for call distribution.
|
|
11
|
+
Team names must be unique within a company (max 64 characters).
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def list_teams(self, page: int = 1, per_page: int = 20) -> list[Team]:
|
|
15
|
+
"""
|
|
16
|
+
List all teams with pagination.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
page: Page number (default 1)
|
|
20
|
+
per_page: Results per page (default 20, max 50)
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
list[Team]: List of Team objects
|
|
24
|
+
"""
|
|
25
|
+
response = self._get("/teams", params={"page": page, "per_page": per_page})
|
|
26
|
+
return [Team(**t) for t in response["teams"]]
|
|
27
|
+
|
|
28
|
+
def get(self, team_id: int) -> Team:
|
|
29
|
+
"""
|
|
30
|
+
Get a specific team by ID.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
team_id: The ID of the team to retrieve
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Team: The team object
|
|
37
|
+
"""
|
|
38
|
+
response = self._get(f"/teams/{team_id}")
|
|
39
|
+
return Team(**response["team"])
|
|
40
|
+
|
|
41
|
+
def create(self, name: str, **kwargs) -> Team:
|
|
42
|
+
"""
|
|
43
|
+
Create a new team.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
name: Team name (max 64 characters, must be unique in company)
|
|
47
|
+
**kwargs: Additional team data
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Team: The created team object
|
|
51
|
+
"""
|
|
52
|
+
data = {"name": name, **kwargs}
|
|
53
|
+
response = self._post("/teams", json=data)
|
|
54
|
+
return Team(**response["team"])
|
|
55
|
+
|
|
56
|
+
def delete(self, team_id: int) -> dict:
|
|
57
|
+
"""
|
|
58
|
+
Delete a team.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
team_id: The ID of the team to delete
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
dict: Delete response
|
|
65
|
+
"""
|
|
66
|
+
return self._delete(f"/teams/{team_id}")
|
|
67
|
+
|
|
68
|
+
def add_user(self, team_id: int, user_id: int) -> dict:
|
|
69
|
+
"""
|
|
70
|
+
Add a user to a team.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
team_id: The ID of the team
|
|
74
|
+
user_id: The ID of the user to add
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
dict: Add user response
|
|
78
|
+
"""
|
|
79
|
+
return self._post(f"/teams/{team_id}/users/{user_id}")
|
|
80
|
+
|
|
81
|
+
def remove_user(self, team_id: int, user_id: int) -> dict:
|
|
82
|
+
"""
|
|
83
|
+
Remove a user from a team.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
team_id: The ID of the team
|
|
87
|
+
user_id: The ID of the user to remove
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
dict: Remove user response
|
|
91
|
+
"""
|
|
92
|
+
return self._delete(f"/teams/{team_id}/users/{user_id}")
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Resource module for managing users"""
|
|
2
|
+
from aircall.resources.base import BaseResource
|
|
3
|
+
from aircall.models import User, UserAvailability
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UserResource(BaseResource):
|
|
7
|
+
"""
|
|
8
|
+
API Resource for Aircall Users.
|
|
9
|
+
|
|
10
|
+
Handles operations relating to users including availability and outbound calls.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def list_users(self, page: int = 1, per_page: int = 20) -> list[User]:
|
|
14
|
+
"""
|
|
15
|
+
List all users with pagination.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
page: Page number (default 1)
|
|
19
|
+
per_page: Results per page (default 20, max 50)
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
list[User]: List of User objects
|
|
23
|
+
"""
|
|
24
|
+
response = self._get("/users", params={"page": page, "per_page": per_page})
|
|
25
|
+
return [User(**u) for u in response["users"]]
|
|
26
|
+
|
|
27
|
+
def get(self, user_id: int) -> User:
|
|
28
|
+
"""
|
|
29
|
+
Get a specific user by ID.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
user_id: The ID of the user to retrieve
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
User: The user object
|
|
36
|
+
"""
|
|
37
|
+
response = self._get(f"/users/{user_id}")
|
|
38
|
+
return User(**response["user"])
|
|
39
|
+
|
|
40
|
+
def create(self, email: str, **kwargs) -> User:
|
|
41
|
+
"""
|
|
42
|
+
Create a new user.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
email: User email address
|
|
46
|
+
**kwargs: Additional user data (name, time_zone, language, etc.)
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
User: The created user object
|
|
50
|
+
"""
|
|
51
|
+
data = {"email": email, **kwargs}
|
|
52
|
+
response = self._post("/users", json=data)
|
|
53
|
+
return User(**response["user"])
|
|
54
|
+
|
|
55
|
+
def update(self, user_id: int, **kwargs) -> User:
|
|
56
|
+
"""
|
|
57
|
+
Update a user.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
user_id: The ID of the user to update
|
|
61
|
+
**kwargs: User fields to update
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
User: The updated user object
|
|
65
|
+
"""
|
|
66
|
+
response = self._put(f"/users/{user_id}", json=kwargs)
|
|
67
|
+
return User(**response["user"])
|
|
68
|
+
|
|
69
|
+
def delete(self, user_id: int) -> dict:
|
|
70
|
+
"""
|
|
71
|
+
Delete a user.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
user_id: The ID of the user to delete
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
dict: Delete response
|
|
78
|
+
"""
|
|
79
|
+
return self._delete(f"/users/{user_id}")
|
|
80
|
+
|
|
81
|
+
def get_availabilities(self) -> dict:
|
|
82
|
+
"""
|
|
83
|
+
Retrieve availability status for all users.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
dict: Dictionary of user availabilities
|
|
87
|
+
"""
|
|
88
|
+
return self._get("/users/availabilities")
|
|
89
|
+
|
|
90
|
+
def get_availability(self, user_id: int) -> UserAvailability:
|
|
91
|
+
"""
|
|
92
|
+
Check availability of a specific user.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
user_id: The ID of the user
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
UserAvailability: Granular availability status
|
|
99
|
+
"""
|
|
100
|
+
response = self._get(f"/users/{user_id}/availability")
|
|
101
|
+
return UserAvailability(**response)
|
|
102
|
+
|
|
103
|
+
def start_call(self, user_id: int, to: str, **kwargs) -> dict:
|
|
104
|
+
"""
|
|
105
|
+
Start an outbound call for a user.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
user_id: The ID of the user making the call
|
|
109
|
+
to: Phone number to call
|
|
110
|
+
**kwargs: Additional call parameters
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
dict: Call response
|
|
114
|
+
"""
|
|
115
|
+
data = {"to": to, **kwargs}
|
|
116
|
+
return self._post(f"/users/{user_id}/calls", json=data)
|
|
117
|
+
|
|
118
|
+
def dial(self, user_id: int, **kwargs) -> dict:
|
|
119
|
+
"""
|
|
120
|
+
Dial a number for a user.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
user_id: The ID of the user
|
|
124
|
+
**kwargs: Dial parameters
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
dict: Dial response
|
|
128
|
+
"""
|
|
129
|
+
return self._post(f"/users/{user_id}/dial", json=kwargs)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Resource module for managing webhooks"""
|
|
2
|
+
from aircall.resources.base import BaseResource
|
|
3
|
+
from aircall.models import Webhook
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WebhookResource(BaseResource):
|
|
7
|
+
"""
|
|
8
|
+
API Resource for Aircall Webhooks.
|
|
9
|
+
|
|
10
|
+
Webhooks are used to receive event notifications from Aircall.
|
|
11
|
+
Use the token field to authenticate incoming webhook requests.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def list_webhooks(self, page: int = 1, per_page: int = 20) -> list[Webhook]:
|
|
15
|
+
"""
|
|
16
|
+
List all webhooks with pagination.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
page: Page number (default 1)
|
|
20
|
+
per_page: Results per page (default 20, max 50)
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
list[Webhook]: List of Webhook objects
|
|
24
|
+
"""
|
|
25
|
+
response = self._get("/webhooks", params={"page": page, "per_page": per_page})
|
|
26
|
+
return [Webhook(**w) for w in response["webhooks"]]
|
|
27
|
+
|
|
28
|
+
def get(self, webhook_id: str) -> Webhook:
|
|
29
|
+
"""
|
|
30
|
+
Get a specific webhook by ID.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
webhook_id: The UUID of the webhook to retrieve
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Webhook: The webhook object
|
|
37
|
+
"""
|
|
38
|
+
response = self._get(f"/webhooks/{webhook_id}")
|
|
39
|
+
return Webhook(**response["webhook"])
|
|
40
|
+
|
|
41
|
+
def create(self, url: str, events: list[str], custom_name: str = "Webhook", **kwargs) -> Webhook:
|
|
42
|
+
"""
|
|
43
|
+
Create a new webhook.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
url: Valid URL to your web server
|
|
47
|
+
events: List of event names to subscribe to
|
|
48
|
+
custom_name: Custom name for the webhook (default: "Webhook")
|
|
49
|
+
**kwargs: Additional webhook data
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Webhook: The created webhook object
|
|
53
|
+
"""
|
|
54
|
+
data = {"url": url, "events": events, "custom_name": custom_name, **kwargs}
|
|
55
|
+
response = self._post("/webhooks", json=data)
|
|
56
|
+
return Webhook(**response["webhook"])
|
|
57
|
+
|
|
58
|
+
def update(self, webhook_id: str, **kwargs) -> Webhook:
|
|
59
|
+
"""
|
|
60
|
+
Update a webhook.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
webhook_id: The UUID of the webhook to update
|
|
64
|
+
**kwargs: Webhook fields to update (url, events, custom_name, active, etc.)
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Webhook: The updated webhook object
|
|
68
|
+
"""
|
|
69
|
+
response = self._put(f"/webhooks/{webhook_id}", json=kwargs)
|
|
70
|
+
return Webhook(**response["webhook"])
|
|
71
|
+
|
|
72
|
+
def delete(self, webhook_id: str) -> dict:
|
|
73
|
+
"""
|
|
74
|
+
Delete a webhook.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
webhook_id: The UUID of the webhook to delete
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
dict: Delete response
|
|
81
|
+
"""
|
|
82
|
+
return self._delete(f"/webhooks/{webhook_id}")
|