blueticks 3.3.2__tar.gz → 4.0.0__tar.gz
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.
- {blueticks-3.3.2/src/blueticks.egg-info → blueticks-4.0.0}/PKG-INFO +22 -2
- blueticks-4.0.0/README.md +42 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/_client.py +4 -2
- blueticks-4.0.0/src/blueticks/_version.py +1 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/resources/__init__.py +4 -2
- blueticks-4.0.0/src/blueticks/resources/account.py +14 -0
- blueticks-4.0.0/src/blueticks/resources/audiences.py +136 -0
- blueticks-4.0.0/src/blueticks/resources/campaigns.py +83 -0
- blueticks-4.0.0/src/blueticks/resources/chats.py +98 -0
- blueticks-4.0.0/src/blueticks/resources/contacts.py +46 -0
- blueticks-4.0.0/src/blueticks/resources/engines.py +18 -0
- blueticks-4.0.0/src/blueticks/resources/groups.py +132 -0
- blueticks-4.0.0/src/blueticks/resources/messages.py +243 -0
- blueticks-4.0.0/src/blueticks/resources/newsletters.py +59 -0
- blueticks-4.0.0/src/blueticks/resources/ping.py +15 -0
- blueticks-4.0.0/src/blueticks/resources/scheduled_messages.py +176 -0
- blueticks-4.0.0/src/blueticks/resources/suno.py +96 -0
- blueticks-4.0.0/src/blueticks/resources/webhooks.py +75 -0
- blueticks-4.0.0/src/blueticks/types/__init__.py +89 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/types/account.py +5 -3
- blueticks-4.0.0/src/blueticks/types/audiences.py +47 -0
- blueticks-4.0.0/src/blueticks/types/campaigns.py +37 -0
- blueticks-4.0.0/src/blueticks/types/chats.py +50 -0
- blueticks-4.0.0/src/blueticks/types/contacts.py +17 -0
- blueticks-4.0.0/src/blueticks/types/engines.py +27 -0
- blueticks-4.0.0/src/blueticks/types/groups.py +55 -0
- blueticks-4.0.0/src/blueticks/types/messages.py +129 -0
- blueticks-4.0.0/src/blueticks/types/newsletters.py +42 -0
- blueticks-4.0.0/src/blueticks/types/page.py +29 -0
- blueticks-4.0.0/src/blueticks/types/ping.py +35 -0
- blueticks-4.0.0/src/blueticks/types/scheduled_messages.py +88 -0
- blueticks-4.0.0/src/blueticks/types/suno.py +54 -0
- blueticks-4.0.0/src/blueticks/types/webhooks.py +68 -0
- {blueticks-3.3.2 → blueticks-4.0.0/src/blueticks.egg-info}/PKG-INFO +22 -2
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks.egg-info/SOURCES.txt +9 -3
- blueticks-4.0.0/tests/test_account.py +69 -0
- blueticks-4.0.0/tests/test_audiences.py +182 -0
- blueticks-4.0.0/tests/test_campaigns.py +149 -0
- blueticks-4.0.0/tests/test_chats.py +137 -0
- blueticks-4.0.0/tests/test_contacts.py +97 -0
- blueticks-4.0.0/tests/test_engines.py +114 -0
- blueticks-4.0.0/tests/test_groups.py +217 -0
- blueticks-4.0.0/tests/test_messages.py +322 -0
- blueticks-4.0.0/tests/test_newsletters.py +125 -0
- blueticks-4.0.0/tests/test_ping.py +75 -0
- blueticks-4.0.0/tests/test_scheduled_messages.py +199 -0
- blueticks-4.0.0/tests/test_suno.py +131 -0
- blueticks-4.0.0/tests/test_types.py +116 -0
- blueticks-4.0.0/tests/test_webhooks.py +132 -0
- blueticks-3.3.2/README.md +0 -22
- blueticks-3.3.2/src/blueticks/_version.py +0 -1
- blueticks-3.3.2/src/blueticks/resources/account.py +0 -14
- blueticks-3.3.2/src/blueticks/resources/audiences.py +0 -95
- blueticks-3.3.2/src/blueticks/resources/campaigns.py +0 -65
- blueticks-3.3.2/src/blueticks/resources/chats.py +0 -156
- blueticks-3.3.2/src/blueticks/resources/contacts.py +0 -32
- blueticks-3.3.2/src/blueticks/resources/engines.py +0 -26
- blueticks-3.3.2/src/blueticks/resources/groups.py +0 -80
- blueticks-3.3.2/src/blueticks/resources/messages.py +0 -61
- blueticks-3.3.2/src/blueticks/resources/ping.py +0 -14
- blueticks-3.3.2/src/blueticks/resources/scheduled_messages.py +0 -73
- blueticks-3.3.2/src/blueticks/resources/utils.py +0 -20
- blueticks-3.3.2/src/blueticks/resources/webhooks.py +0 -81
- blueticks-3.3.2/src/blueticks/types/__init__.py +0 -52
- blueticks-3.3.2/src/blueticks/types/audiences.py +0 -37
- blueticks-3.3.2/src/blueticks/types/campaigns.py +0 -34
- blueticks-3.3.2/src/blueticks/types/chats.py +0 -175
- blueticks-3.3.2/src/blueticks/types/contacts.py +0 -20
- blueticks-3.3.2/src/blueticks/types/engines.py +0 -23
- blueticks-3.3.2/src/blueticks/types/groups.py +0 -30
- blueticks-3.3.2/src/blueticks/types/messages.py +0 -26
- blueticks-3.3.2/src/blueticks/types/page.py +0 -24
- blueticks-3.3.2/src/blueticks/types/ping.py +0 -14
- blueticks-3.3.2/src/blueticks/types/scheduled_messages.py +0 -26
- blueticks-3.3.2/src/blueticks/types/utils.py +0 -22
- blueticks-3.3.2/src/blueticks/types/webhooks.py +0 -47
- blueticks-3.3.2/tests/test_account.py +0 -89
- blueticks-3.3.2/tests/test_audiences.py +0 -149
- blueticks-3.3.2/tests/test_campaigns.py +0 -115
- blueticks-3.3.2/tests/test_chats.py +0 -270
- blueticks-3.3.2/tests/test_groups.py +0 -175
- blueticks-3.3.2/tests/test_messages.py +0 -133
- blueticks-3.3.2/tests/test_ping.py +0 -66
- blueticks-3.3.2/tests/test_scheduled_messages.py +0 -161
- blueticks-3.3.2/tests/test_types.py +0 -113
- blueticks-3.3.2/tests/test_webhooks_resource.py +0 -113
- {blueticks-3.3.2 → blueticks-4.0.0}/LICENSE +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/pyproject.toml +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/setup.cfg +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/__init__.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/_base_resource.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/_errors.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/_transport.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/py.typed +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/types/_deleted_resource.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks/webhooks.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks.egg-info/dependency_links.txt +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks.egg-info/requires.txt +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/src/blueticks.egg-info/top_level.txt +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/tests/test_client.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/tests/test_errors.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/tests/test_transport.py +0 -0
- {blueticks-3.3.2 → blueticks-4.0.0}/tests/test_webhook_verify.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blueticks
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Official Python client for the Blueticks API.
|
|
5
5
|
Author-email: Blueticks <support@blueticks.co>
|
|
6
6
|
License: MIT License
|
|
@@ -66,10 +66,30 @@ pip install blueticks
|
|
|
66
66
|
```python
|
|
67
67
|
from blueticks import Blueticks
|
|
68
68
|
|
|
69
|
-
client = Blueticks(api_key="
|
|
69
|
+
client = Blueticks(api_key="BLUETICKS_API_KEY")
|
|
70
70
|
ping = client.ping()
|
|
71
71
|
account = client.account.retrieve()
|
|
72
72
|
print(account.name)
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
See https://docs.blueticks.co for full documentation.
|
|
76
|
+
|
|
77
|
+
## Migrating from 3.x → 4.0
|
|
78
|
+
|
|
79
|
+
The backend renamed the queued-send domain on the wire: `POST/GET/PATCH /v1/messages*` → `POST/GET/PATCH /v1/scheduled-messages*`. To match, the SDK has dropped the `client.messages` resource and moved every queued-send method onto `client.scheduled_messages`. The legacy `client.messages.send(...)` is renamed to `client.scheduled_messages.create(...)`.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
# Before (3.x)
|
|
83
|
+
client.messages.send(to="+1...", type="text", text="hi")
|
|
84
|
+
client.messages.retrieve("msg_1")
|
|
85
|
+
client.messages.list()
|
|
86
|
+
client.messages.update("msg_1", text="edited")
|
|
87
|
+
|
|
88
|
+
# After (4.0)
|
|
89
|
+
client.scheduled_messages.create(to="+1...", type="text", text="hi")
|
|
90
|
+
client.scheduled_messages.retrieve("msg_1")
|
|
91
|
+
client.scheduled_messages.list()
|
|
92
|
+
client.scheduled_messages.update("msg_1", text="edited")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The response type was likewise renamed `Message` → `ScheduledMessage` (same fields). Import from `blueticks.types.scheduled_messages` instead of `blueticks.types.messages`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# blueticks — Python client for the Blueticks API
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [Blueticks](https://blueticks.co).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install blueticks
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from blueticks import Blueticks
|
|
15
|
+
|
|
16
|
+
client = Blueticks(api_key="BLUETICKS_API_KEY")
|
|
17
|
+
ping = client.ping()
|
|
18
|
+
account = client.account.retrieve()
|
|
19
|
+
print(account.name)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
See https://docs.blueticks.co for full documentation.
|
|
23
|
+
|
|
24
|
+
## Migrating from 3.x → 4.0
|
|
25
|
+
|
|
26
|
+
The backend renamed the queued-send domain on the wire: `POST/GET/PATCH /v1/messages*` → `POST/GET/PATCH /v1/scheduled-messages*`. To match, the SDK has dropped the `client.messages` resource and moved every queued-send method onto `client.scheduled_messages`. The legacy `client.messages.send(...)` is renamed to `client.scheduled_messages.create(...)`.
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
# Before (3.x)
|
|
30
|
+
client.messages.send(to="+1...", type="text", text="hi")
|
|
31
|
+
client.messages.retrieve("msg_1")
|
|
32
|
+
client.messages.list()
|
|
33
|
+
client.messages.update("msg_1", text="edited")
|
|
34
|
+
|
|
35
|
+
# After (4.0)
|
|
36
|
+
client.scheduled_messages.create(to="+1...", type="text", text="hi")
|
|
37
|
+
client.scheduled_messages.retrieve("msg_1")
|
|
38
|
+
client.scheduled_messages.list()
|
|
39
|
+
client.scheduled_messages.update("msg_1", text="edited")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The response type was likewise renamed `Message` → `ScheduledMessage` (same fields). Import from `blueticks.types.scheduled_messages` instead of `blueticks.types.messages`.
|
|
@@ -69,8 +69,9 @@ class Blueticks:
|
|
|
69
69
|
from blueticks.resources.engines import EnginesResource
|
|
70
70
|
from blueticks.resources.groups import GroupsResource
|
|
71
71
|
from blueticks.resources.messages import MessagesResource
|
|
72
|
+
from blueticks.resources.newsletters import NewslettersResource
|
|
72
73
|
from blueticks.resources.scheduled_messages import ScheduledMessagesResource
|
|
73
|
-
from blueticks.resources.
|
|
74
|
+
from blueticks.resources.suno import SunoResource
|
|
74
75
|
from blueticks.resources.webhooks import WebhooksResource
|
|
75
76
|
|
|
76
77
|
self.account = AccountResource(self)
|
|
@@ -81,8 +82,9 @@ class Blueticks:
|
|
|
81
82
|
self.engines = EnginesResource(self)
|
|
82
83
|
self.groups = GroupsResource(self)
|
|
83
84
|
self.messages = MessagesResource(self)
|
|
85
|
+
self.newsletters = NewslettersResource(self)
|
|
84
86
|
self.scheduled_messages = ScheduledMessagesResource(self)
|
|
85
|
-
self.
|
|
87
|
+
self.suno = SunoResource(self)
|
|
86
88
|
self.webhooks = WebhooksResource(self)
|
|
87
89
|
|
|
88
90
|
# -- Public API ----------------------------------------------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "4.0.0"
|
|
@@ -6,9 +6,10 @@ from blueticks.resources.contacts import ContactsResource
|
|
|
6
6
|
from blueticks.resources.engines import EnginesResource
|
|
7
7
|
from blueticks.resources.groups import GroupsResource
|
|
8
8
|
from blueticks.resources.messages import MessagesResource
|
|
9
|
+
from blueticks.resources.newsletters import NewslettersResource
|
|
9
10
|
from blueticks.resources.ping import PingResource
|
|
10
11
|
from blueticks.resources.scheduled_messages import ScheduledMessagesResource
|
|
11
|
-
from blueticks.resources.
|
|
12
|
+
from blueticks.resources.suno import SunoResource
|
|
12
13
|
from blueticks.resources.webhooks import WebhooksResource
|
|
13
14
|
|
|
14
15
|
__all__ = [
|
|
@@ -20,8 +21,9 @@ __all__ = [
|
|
|
20
21
|
"EnginesResource",
|
|
21
22
|
"GroupsResource",
|
|
22
23
|
"MessagesResource",
|
|
24
|
+
"NewslettersResource",
|
|
23
25
|
"PingResource",
|
|
24
26
|
"ScheduledMessagesResource",
|
|
25
|
-
"
|
|
27
|
+
"SunoResource",
|
|
26
28
|
"WebhooksResource",
|
|
27
29
|
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from blueticks._base_resource import BaseResource
|
|
4
|
+
from blueticks.types.account import Account
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AccountResource(BaseResource):
|
|
8
|
+
def retrieve(self) -> Account:
|
|
9
|
+
"""Get account.
|
|
10
|
+
|
|
11
|
+
Retrieve the account the API key belongs to.
|
|
12
|
+
"""
|
|
13
|
+
envelope = self._client._request("GET", "/v1/account")
|
|
14
|
+
return Account.model_validate(envelope["data"])
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import builtins
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from blueticks._base_resource import BaseResource
|
|
7
|
+
from blueticks.types._deleted_resource import DeletedResource
|
|
8
|
+
from blueticks.types.audiences import (
|
|
9
|
+
AppendContactsResult,
|
|
10
|
+
Audience,
|
|
11
|
+
AudienceContact,
|
|
12
|
+
RemovedContact,
|
|
13
|
+
)
|
|
14
|
+
from blueticks.types.page import Page
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AudiencesResource(BaseResource):
|
|
18
|
+
def list(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
order: str | None = None,
|
|
22
|
+
skip: int | None = None,
|
|
23
|
+
limit: int | None = None,
|
|
24
|
+
) -> Page[Audience]:
|
|
25
|
+
"""List audiences.
|
|
26
|
+
|
|
27
|
+
List the audiences in your workspace, newest first. Offset-paginated via
|
|
28
|
+
``limit`` + ``skip``. Requires ``audiences:read``.
|
|
29
|
+
"""
|
|
30
|
+
params: dict[str, Any] = {}
|
|
31
|
+
if order is not None:
|
|
32
|
+
params["order"] = order
|
|
33
|
+
if skip is not None:
|
|
34
|
+
params["skip"] = skip
|
|
35
|
+
if limit is not None:
|
|
36
|
+
params["limit"] = limit
|
|
37
|
+
envelope = self._client._request("GET", "/v1/audiences", params=params or None)
|
|
38
|
+
return Page[Audience].model_validate(envelope)
|
|
39
|
+
|
|
40
|
+
def create(
|
|
41
|
+
self,
|
|
42
|
+
*,
|
|
43
|
+
name: str,
|
|
44
|
+
contacts: builtins.list[dict[str, Any]] | None = None,
|
|
45
|
+
) -> Audience:
|
|
46
|
+
"""Create audience.
|
|
47
|
+
|
|
48
|
+
Create a new audience. Returns the audience with ``contact_count: 0``.
|
|
49
|
+
Requires ``audiences:write``.
|
|
50
|
+
"""
|
|
51
|
+
body: dict[str, Any] = {"name": name}
|
|
52
|
+
if contacts is not None:
|
|
53
|
+
body["contacts"] = contacts
|
|
54
|
+
envelope = self._client._request("POST", "/v1/audiences", body=body)
|
|
55
|
+
return Audience.model_validate(envelope["data"])
|
|
56
|
+
|
|
57
|
+
def get(self, audience_id: str) -> Audience:
|
|
58
|
+
"""Get audience.
|
|
59
|
+
|
|
60
|
+
Retrieve a single audience by id, including its ``contact_count`` and
|
|
61
|
+
variable schema. Requires ``audiences:read``.
|
|
62
|
+
"""
|
|
63
|
+
envelope = self._client._request("GET", f"/v1/audiences/{audience_id}")
|
|
64
|
+
return Audience.model_validate(envelope["data"])
|
|
65
|
+
|
|
66
|
+
def update(self, audience_id: str, *, name: str) -> Audience:
|
|
67
|
+
"""Update audience.
|
|
68
|
+
|
|
69
|
+
Rename an audience or update its variable schema. Requires
|
|
70
|
+
``audiences:write``.
|
|
71
|
+
"""
|
|
72
|
+
envelope = self._client._request(
|
|
73
|
+
"PATCH", f"/v1/audiences/{audience_id}", body={"name": name}
|
|
74
|
+
)
|
|
75
|
+
return Audience.model_validate(envelope["data"])
|
|
76
|
+
|
|
77
|
+
def delete(self, audience_id: str) -> DeletedResource:
|
|
78
|
+
"""Delete audience.
|
|
79
|
+
|
|
80
|
+
Soft-delete an audience. 409 if it's referenced by an active campaign.
|
|
81
|
+
Returns the deleted ref. Requires ``audiences:write``.
|
|
82
|
+
"""
|
|
83
|
+
envelope = self._client._request("DELETE", f"/v1/audiences/{audience_id}")
|
|
84
|
+
return DeletedResource.model_validate(envelope["data"])
|
|
85
|
+
|
|
86
|
+
def append_contacts(
|
|
87
|
+
self,
|
|
88
|
+
audience_id: str,
|
|
89
|
+
*,
|
|
90
|
+
contacts: builtins.list[dict[str, Any]],
|
|
91
|
+
) -> AppendContactsResult:
|
|
92
|
+
"""Append contacts to audience.
|
|
93
|
+
|
|
94
|
+
Append contacts to an audience. Duplicates (by ``to``) are skipped.
|
|
95
|
+
Requires ``audiences:write``.
|
|
96
|
+
"""
|
|
97
|
+
envelope = self._client._request(
|
|
98
|
+
"POST",
|
|
99
|
+
f"/v1/audiences/{audience_id}/contacts",
|
|
100
|
+
body={"contacts": contacts},
|
|
101
|
+
)
|
|
102
|
+
return AppendContactsResult.model_validate(envelope["data"])
|
|
103
|
+
|
|
104
|
+
def update_contact(
|
|
105
|
+
self,
|
|
106
|
+
audience_id: str,
|
|
107
|
+
contact_id: str,
|
|
108
|
+
*,
|
|
109
|
+
to: str | None = None,
|
|
110
|
+
variables: dict[str, Any] | None = None,
|
|
111
|
+
) -> AudienceContact:
|
|
112
|
+
"""Update audience contact.
|
|
113
|
+
|
|
114
|
+
Edit a contact's phone or variables. Requires ``audiences:write``.
|
|
115
|
+
"""
|
|
116
|
+
body: dict[str, Any] = {}
|
|
117
|
+
if to is not None:
|
|
118
|
+
body["to"] = to
|
|
119
|
+
if variables is not None:
|
|
120
|
+
body["variables"] = variables
|
|
121
|
+
envelope = self._client._request(
|
|
122
|
+
"PATCH",
|
|
123
|
+
f"/v1/audiences/{audience_id}/contacts/{contact_id}",
|
|
124
|
+
body=body,
|
|
125
|
+
)
|
|
126
|
+
return AudienceContact.model_validate(envelope["data"])
|
|
127
|
+
|
|
128
|
+
def delete_contact(self, audience_id: str, contact_id: str) -> RemovedContact:
|
|
129
|
+
"""Remove audience contact.
|
|
130
|
+
|
|
131
|
+
Remove a contact from an audience. Requires ``audiences:write``.
|
|
132
|
+
"""
|
|
133
|
+
envelope = self._client._request(
|
|
134
|
+
"DELETE", f"/v1/audiences/{audience_id}/contacts/{contact_id}"
|
|
135
|
+
)
|
|
136
|
+
return RemovedContact.model_validate(envelope["data"])
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from blueticks._base_resource import BaseResource
|
|
6
|
+
from blueticks.types.campaigns import Campaign
|
|
7
|
+
from blueticks.types.page import Page
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CampaignsResource(BaseResource):
|
|
11
|
+
def list(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
order: str | None = None,
|
|
15
|
+
skip: int | None = None,
|
|
16
|
+
limit: int | None = None,
|
|
17
|
+
) -> Page[Campaign]:
|
|
18
|
+
"""List campaigns.
|
|
19
|
+
|
|
20
|
+
List the campaigns in your workspace, newest first, each with its live
|
|
21
|
+
counters. Offset-paginated via ``limit`` + ``skip``. Requires
|
|
22
|
+
``campaigns:read``.
|
|
23
|
+
"""
|
|
24
|
+
params: dict[str, Any] = {}
|
|
25
|
+
if order is not None:
|
|
26
|
+
params["order"] = order
|
|
27
|
+
if skip is not None:
|
|
28
|
+
params["skip"] = skip
|
|
29
|
+
if limit is not None:
|
|
30
|
+
params["limit"] = limit
|
|
31
|
+
envelope = self._client._request("GET", "/v1/campaigns", params=params or None)
|
|
32
|
+
return Page[Campaign].model_validate(envelope)
|
|
33
|
+
|
|
34
|
+
def create(
|
|
35
|
+
self,
|
|
36
|
+
*,
|
|
37
|
+
name: str,
|
|
38
|
+
audience_id: str,
|
|
39
|
+
text: str | None = None,
|
|
40
|
+
media_url: str | None = None,
|
|
41
|
+
media_caption: str | None = None,
|
|
42
|
+
on_missing_variable: str | None = None,
|
|
43
|
+
) -> Campaign:
|
|
44
|
+
"""Create campaign.
|
|
45
|
+
|
|
46
|
+
Schedule a new bulk-message campaign. Returns the campaign in ``pending``
|
|
47
|
+
state. Requires ``campaigns:write``.
|
|
48
|
+
"""
|
|
49
|
+
body: dict[str, Any] = {"name": name, "audienceId": audience_id}
|
|
50
|
+
if text is not None:
|
|
51
|
+
body["text"] = text
|
|
52
|
+
if media_url is not None:
|
|
53
|
+
body["mediaUrl"] = media_url
|
|
54
|
+
if media_caption is not None:
|
|
55
|
+
body["mediaCaption"] = media_caption
|
|
56
|
+
if on_missing_variable is not None:
|
|
57
|
+
body["onMissingVariable"] = on_missing_variable
|
|
58
|
+
envelope = self._client._request("POST", "/v1/campaigns", body=body)
|
|
59
|
+
return Campaign.model_validate(envelope["data"])
|
|
60
|
+
|
|
61
|
+
def get(self, campaign_id: str) -> Campaign:
|
|
62
|
+
"""Get campaign.
|
|
63
|
+
|
|
64
|
+
Retrieve a single campaign by id, including its status and live delivery
|
|
65
|
+
counters. Poll this to track progress. Requires ``campaigns:read``.
|
|
66
|
+
"""
|
|
67
|
+
envelope = self._client._request("GET", f"/v1/campaigns/{campaign_id}")
|
|
68
|
+
return Campaign.model_validate(envelope["data"])
|
|
69
|
+
|
|
70
|
+
def pause(self, campaign_id: str) -> Campaign:
|
|
71
|
+
"""Pause a running campaign. 409 if not ``running``. Requires ``campaigns:write``."""
|
|
72
|
+
envelope = self._client._request("POST", f"/v1/campaigns/{campaign_id}/pause")
|
|
73
|
+
return Campaign.model_validate(envelope["data"])
|
|
74
|
+
|
|
75
|
+
def resume(self, campaign_id: str) -> Campaign:
|
|
76
|
+
"""Resume a paused campaign. 409 if not ``paused``. Requires ``campaigns:write``."""
|
|
77
|
+
envelope = self._client._request("POST", f"/v1/campaigns/{campaign_id}/resume")
|
|
78
|
+
return Campaign.model_validate(envelope["data"])
|
|
79
|
+
|
|
80
|
+
def cancel(self, campaign_id: str) -> Campaign:
|
|
81
|
+
"""Cancel a campaign. 409 if already terminal. Requires ``campaigns:write``."""
|
|
82
|
+
envelope = self._client._request("POST", f"/v1/campaigns/{campaign_id}/cancel")
|
|
83
|
+
return Campaign.model_validate(envelope["data"])
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from blueticks._base_resource import BaseResource
|
|
6
|
+
from blueticks.types.chats import Chat, ChatType, OkResponse, Participant
|
|
7
|
+
from blueticks.types.page import Page
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ChatsResource(BaseResource):
|
|
11
|
+
def list(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
search_token: str | None = None,
|
|
15
|
+
filter: ChatType | None = None, # noqa: A002
|
|
16
|
+
include_last_message: bool | None = None,
|
|
17
|
+
include_extended_info: bool | None = None,
|
|
18
|
+
include_without_name: bool | None = None,
|
|
19
|
+
include_archive: bool | None = None,
|
|
20
|
+
skip: int | None = None,
|
|
21
|
+
limit: int | None = None,
|
|
22
|
+
) -> Page[Chat]:
|
|
23
|
+
"""List chats.
|
|
24
|
+
|
|
25
|
+
List the chats (conversations) the connected WhatsApp engine sees,
|
|
26
|
+
most-recent first. Offset-paginated via ``limit`` + ``skip``, with an
|
|
27
|
+
optional case-insensitive name search via ``search_token`` and a
|
|
28
|
+
``filter`` to restrict to one chat kind. Requires ``chats:read``.
|
|
29
|
+
"""
|
|
30
|
+
params: dict[str, Any] = {}
|
|
31
|
+
if search_token is not None:
|
|
32
|
+
params["searchToken"] = search_token
|
|
33
|
+
if filter is not None:
|
|
34
|
+
params["filter"] = filter
|
|
35
|
+
if include_last_message is not None:
|
|
36
|
+
params["includeLastMessage"] = include_last_message
|
|
37
|
+
if include_extended_info is not None:
|
|
38
|
+
params["includeExtendedInfo"] = include_extended_info
|
|
39
|
+
if include_without_name is not None:
|
|
40
|
+
params["includeWithoutName"] = include_without_name
|
|
41
|
+
if include_archive is not None:
|
|
42
|
+
params["includeArchive"] = include_archive
|
|
43
|
+
if skip is not None:
|
|
44
|
+
params["skip"] = skip
|
|
45
|
+
if limit is not None:
|
|
46
|
+
params["limit"] = limit
|
|
47
|
+
envelope = self._client._request("GET", "/v1/chats", params=params or None)
|
|
48
|
+
return Page[Chat].model_validate(envelope)
|
|
49
|
+
|
|
50
|
+
def get(self, chat_id: str) -> Chat:
|
|
51
|
+
"""Get chat.
|
|
52
|
+
|
|
53
|
+
Retrieve a single chat by its id — a phone number in international format
|
|
54
|
+
(e.g. +14155551234) or a WhatsApp JID (``@c.us``, ``@g.us``, or
|
|
55
|
+
``@newsletter``). Requires ``chats:read``.
|
|
56
|
+
"""
|
|
57
|
+
envelope = self._client._request("GET", f"/v1/chats/{chat_id}")
|
|
58
|
+
return Chat.model_validate(envelope["data"])
|
|
59
|
+
|
|
60
|
+
def list_participants(
|
|
61
|
+
self,
|
|
62
|
+
chat_id: str,
|
|
63
|
+
*,
|
|
64
|
+
search_token: str | None = None,
|
|
65
|
+
skip: int | None = None,
|
|
66
|
+
limit: int | None = None,
|
|
67
|
+
) -> Page[Participant]:
|
|
68
|
+
"""List chat participants.
|
|
69
|
+
|
|
70
|
+
For group chats, returns the participant list (paginated). For DMs,
|
|
71
|
+
returns the single counterparty. Requires ``chats:read``.
|
|
72
|
+
"""
|
|
73
|
+
params: dict[str, Any] = {}
|
|
74
|
+
if search_token is not None:
|
|
75
|
+
params["searchToken"] = search_token
|
|
76
|
+
if skip is not None:
|
|
77
|
+
params["skip"] = skip
|
|
78
|
+
if limit is not None:
|
|
79
|
+
params["limit"] = limit
|
|
80
|
+
envelope = self._client._request(
|
|
81
|
+
"GET", f"/v1/chats/{chat_id}/participants", params=params or None
|
|
82
|
+
)
|
|
83
|
+
return Page[Participant].model_validate(envelope)
|
|
84
|
+
|
|
85
|
+
def archive(self, chat_id: str) -> OkResponse:
|
|
86
|
+
"""Archive a chat on the connected engine, hiding it from the main list."""
|
|
87
|
+
envelope = self._client._request("POST", f"/v1/chats/{chat_id}/archive")
|
|
88
|
+
return OkResponse.model_validate(envelope["data"])
|
|
89
|
+
|
|
90
|
+
def unarchive(self, chat_id: str) -> OkResponse:
|
|
91
|
+
"""Remove a chat from the archive, restoring it to the main chat list."""
|
|
92
|
+
envelope = self._client._request("POST", f"/v1/chats/{chat_id}/unarchive")
|
|
93
|
+
return OkResponse.model_validate(envelope["data"])
|
|
94
|
+
|
|
95
|
+
def mark_read(self, chat_id: str) -> OkResponse:
|
|
96
|
+
"""Clear the unread badge on the connected engine for the given chat."""
|
|
97
|
+
envelope = self._client._request("POST", f"/v1/chats/{chat_id}/mark_read")
|
|
98
|
+
return OkResponse.model_validate(envelope["data"])
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from blueticks._base_resource import BaseResource
|
|
6
|
+
from blueticks.types.contacts import Contact
|
|
7
|
+
from blueticks.types.groups import GroupListItem
|
|
8
|
+
from blueticks.types.page import Page
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ContactsResource(BaseResource):
|
|
12
|
+
def list(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
search_token: str | None = None,
|
|
16
|
+
include_archive: bool | None = None,
|
|
17
|
+
skip: int | None = None,
|
|
18
|
+
limit: int | None = None,
|
|
19
|
+
) -> Page[Contact]:
|
|
20
|
+
"""List contacts.
|
|
21
|
+
|
|
22
|
+
List your workspace contact book — everyone the connected WhatsApp
|
|
23
|
+
account has messaged. Offset-paginated via ``limit`` + ``skip``. Requires
|
|
24
|
+
``contacts:read``.
|
|
25
|
+
"""
|
|
26
|
+
params: dict[str, Any] = {}
|
|
27
|
+
if search_token is not None:
|
|
28
|
+
params["searchToken"] = search_token
|
|
29
|
+
if include_archive is not None:
|
|
30
|
+
params["includeArchive"] = include_archive
|
|
31
|
+
if skip is not None:
|
|
32
|
+
params["skip"] = skip
|
|
33
|
+
if limit is not None:
|
|
34
|
+
params["limit"] = limit
|
|
35
|
+
envelope = self._client._request("GET", "/v1/contacts", params=params or None)
|
|
36
|
+
return Page[Contact].model_validate(envelope)
|
|
37
|
+
|
|
38
|
+
def common_groups(self, contact_id: str) -> Page[GroupListItem]:
|
|
39
|
+
"""Get common groups.
|
|
40
|
+
|
|
41
|
+
List the groups the connected WhatsApp account shares with this contact
|
|
42
|
+
(WhatsApp's "groups in common"). ``contact_id`` is the contact's JID
|
|
43
|
+
(e.g. ``12345@c.us``). Requires ``groups:read``.
|
|
44
|
+
"""
|
|
45
|
+
envelope = self._client._request("GET", f"/v1/contacts/{contact_id}/common_groups")
|
|
46
|
+
return Page[GroupListItem].model_validate(envelope)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from blueticks._base_resource import BaseResource
|
|
4
|
+
from blueticks.types.engines import Engine
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class EnginesResource(BaseResource):
|
|
8
|
+
def list(self) -> list[Engine]:
|
|
9
|
+
"""List engines.
|
|
10
|
+
|
|
11
|
+
List the WhatsApp engines connected to this workspace — one entry per
|
|
12
|
+
online engine. Each entry carries its own ``id`` (the engine session's
|
|
13
|
+
MQTT presence client id), its ``type`` (``gateway`` or ``regular``), and
|
|
14
|
+
its connectivity status. Returns an empty list when no engine is
|
|
15
|
+
connected.
|
|
16
|
+
"""
|
|
17
|
+
envelope = self._client._request("GET", "/v1/engines")
|
|
18
|
+
return [Engine.model_validate(item) for item in envelope["data"]]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import builtins
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from blueticks._base_resource import BaseResource
|
|
7
|
+
from blueticks.types.groups import Group, GroupListItem
|
|
8
|
+
from blueticks.types.page import Page
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class GroupsResource(BaseResource):
|
|
12
|
+
def list(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
search_token: str | None = None,
|
|
16
|
+
include_archive: bool | None = None,
|
|
17
|
+
skip: int | None = None,
|
|
18
|
+
limit: int | None = None,
|
|
19
|
+
) -> Page[GroupListItem]:
|
|
20
|
+
"""List groups.
|
|
21
|
+
|
|
22
|
+
List the groups the connected WhatsApp engine sees. Offset-paginated via
|
|
23
|
+
``limit`` + ``skip`` with an optional case-insensitive name search via
|
|
24
|
+
``search_token``.
|
|
25
|
+
"""
|
|
26
|
+
params: dict[str, Any] = {}
|
|
27
|
+
if search_token is not None:
|
|
28
|
+
params["searchToken"] = search_token
|
|
29
|
+
if include_archive is not None:
|
|
30
|
+
params["includeArchive"] = include_archive
|
|
31
|
+
if skip is not None:
|
|
32
|
+
params["skip"] = skip
|
|
33
|
+
if limit is not None:
|
|
34
|
+
params["limit"] = limit
|
|
35
|
+
envelope = self._client._request("GET", "/v1/groups", params=params or None)
|
|
36
|
+
return Page[GroupListItem].model_validate(envelope)
|
|
37
|
+
|
|
38
|
+
def create(self, *, name: str, participants: builtins.list[str]) -> Group:
|
|
39
|
+
"""Create a WhatsApp group with the given name and initial participants."""
|
|
40
|
+
envelope = self._client._request(
|
|
41
|
+
"POST", "/v1/groups", body={"name": name, "participants": participants}
|
|
42
|
+
)
|
|
43
|
+
return Group.model_validate(envelope["data"])
|
|
44
|
+
|
|
45
|
+
def get(self, group_id: str, *, include: str | None = None) -> Group:
|
|
46
|
+
"""Get group.
|
|
47
|
+
|
|
48
|
+
Retrieve a single group by its ``@g.us`` id, including its subject,
|
|
49
|
+
description, and (with ``include="participants"``) its participant list.
|
|
50
|
+
Requires ``groups:read``.
|
|
51
|
+
"""
|
|
52
|
+
params: dict[str, Any] | None = {"include": include} if include is not None else None
|
|
53
|
+
envelope = self._client._request("GET", f"/v1/groups/{group_id}", params=params)
|
|
54
|
+
return Group.model_validate(envelope["data"])
|
|
55
|
+
|
|
56
|
+
def update(
|
|
57
|
+
self,
|
|
58
|
+
group_id: str,
|
|
59
|
+
*,
|
|
60
|
+
name: str | None = None,
|
|
61
|
+
settings: dict[str, Any] | None = None,
|
|
62
|
+
) -> Group:
|
|
63
|
+
"""Update group metadata. Provide at least one of ``name`` or ``settings``."""
|
|
64
|
+
body: dict[str, Any] = {}
|
|
65
|
+
if name is not None:
|
|
66
|
+
body["name"] = name
|
|
67
|
+
if settings is not None:
|
|
68
|
+
body["settings"] = settings
|
|
69
|
+
envelope = self._client._request("PATCH", f"/v1/groups/{group_id}", body=body)
|
|
70
|
+
return Group.model_validate(envelope["data"])
|
|
71
|
+
|
|
72
|
+
def add_member(
|
|
73
|
+
self,
|
|
74
|
+
group_id: str,
|
|
75
|
+
*,
|
|
76
|
+
chat_id: str | None = None,
|
|
77
|
+
participants: builtins.list[str] | None = None,
|
|
78
|
+
) -> Group:
|
|
79
|
+
"""Add a member to the group by chatId (JID) or phone number (E.164)."""
|
|
80
|
+
body: dict[str, Any] = {}
|
|
81
|
+
if chat_id is not None:
|
|
82
|
+
body["chatId"] = chat_id
|
|
83
|
+
if participants is not None:
|
|
84
|
+
body["participants"] = participants
|
|
85
|
+
envelope = self._client._request("POST", f"/v1/groups/{group_id}/members", body=body)
|
|
86
|
+
return Group.model_validate(envelope["data"])
|
|
87
|
+
|
|
88
|
+
def remove_member(self, group_id: str, chat_id: str) -> Group:
|
|
89
|
+
"""Remove a participant from the group."""
|
|
90
|
+
envelope = self._client._request("DELETE", f"/v1/groups/{group_id}/members/{chat_id}")
|
|
91
|
+
return Group.model_validate(envelope["data"])
|
|
92
|
+
|
|
93
|
+
def promote_admin(self, group_id: str, chat_id: str) -> Group:
|
|
94
|
+
"""Grant admin privileges to a group member."""
|
|
95
|
+
envelope = self._client._request("POST", f"/v1/groups/{group_id}/members/{chat_id}/admin")
|
|
96
|
+
return Group.model_validate(envelope["data"])
|
|
97
|
+
|
|
98
|
+
def demote_admin(self, group_id: str, chat_id: str) -> Group:
|
|
99
|
+
"""Revoke admin privileges from a group member."""
|
|
100
|
+
envelope = self._client._request("DELETE", f"/v1/groups/{group_id}/members/{chat_id}/admin")
|
|
101
|
+
return Group.model_validate(envelope["data"])
|
|
102
|
+
|
|
103
|
+
def set_picture(
|
|
104
|
+
self,
|
|
105
|
+
group_id: str,
|
|
106
|
+
*,
|
|
107
|
+
file_data_url: str | None = None,
|
|
108
|
+
url: str | None = None,
|
|
109
|
+
file_name: str | None = None,
|
|
110
|
+
file_mime_type: str | None = None,
|
|
111
|
+
) -> Group:
|
|
112
|
+
"""Set group picture.
|
|
113
|
+
|
|
114
|
+
Replace the group picture. Provide the image as ``file_data_url`` (base64
|
|
115
|
+
data URL, PNG/JPEG, ≤20 MiB) or ``url`` (https). Requires ``groups:write``.
|
|
116
|
+
"""
|
|
117
|
+
body: dict[str, Any] = {}
|
|
118
|
+
if file_data_url is not None:
|
|
119
|
+
body["fileDataUrl"] = file_data_url
|
|
120
|
+
if url is not None:
|
|
121
|
+
body["url"] = url
|
|
122
|
+
if file_name is not None:
|
|
123
|
+
body["fileName"] = file_name
|
|
124
|
+
if file_mime_type is not None:
|
|
125
|
+
body["fileMimeType"] = file_mime_type
|
|
126
|
+
envelope = self._client._request("PUT", f"/v1/groups/{group_id}/picture", body=body)
|
|
127
|
+
return Group.model_validate(envelope["data"])
|
|
128
|
+
|
|
129
|
+
def leave(self, group_id: str) -> None:
|
|
130
|
+
"""Leave the group as the authenticated identity. Idempotent (204 No Content)."""
|
|
131
|
+
self._client._request("DELETE", f"/v1/groups/{group_id}/members/me")
|
|
132
|
+
return None
|