zapiack 0.1.0__tar.gz → 0.2.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.
- {zapiack-0.1.0/src/zapiack.egg-info → zapiack-0.2.0}/PKG-INFO +1 -1
- {zapiack-0.1.0 → zapiack-0.2.0}/pyproject.toml +1 -1
- zapiack-0.2.0/src/zapiack/_version.py +1 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/client.py +4 -0
- zapiack-0.2.0/src/zapiack/resources/calls.py +68 -0
- zapiack-0.2.0/src/zapiack/resources/realtime.py +36 -0
- {zapiack-0.1.0 → zapiack-0.2.0/src/zapiack.egg-info}/PKG-INFO +1 -1
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack.egg-info/SOURCES.txt +2 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/tests/test_http.py +1 -1
- {zapiack-0.1.0 → zapiack-0.2.0}/tests/test_routes.py +24 -0
- zapiack-0.1.0/src/zapiack/_version.py +0 -1
- {zapiack-0.1.0 → zapiack-0.2.0}/LICENSE +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/README.md +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/setup.cfg +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/__init__.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/_http.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/errors.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/pagination.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/py.typed +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/__init__.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/base.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/email.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/push.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/sms.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/resources/whatsapp.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack/webhooks.py +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack.egg-info/dependency_links.txt +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/src/zapiack.egg-info/top_level.txt +0 -0
- {zapiack-0.1.0 → zapiack-0.2.0}/tests/test_webhooks_pages.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "zapiack"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "The official Zapiack SDK for Python: email, SMS and push notifications from one client."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.2.0"
|
|
@@ -5,8 +5,10 @@ from typing import Callable, Optional
|
|
|
5
5
|
|
|
6
6
|
from ._http import HttpClient, Transport, urllib_transport
|
|
7
7
|
from .errors import ZapiackConfigError
|
|
8
|
+
from .resources.calls import Calls
|
|
8
9
|
from .resources.email import Email
|
|
9
10
|
from .resources.push import Push
|
|
11
|
+
from .resources.realtime import Realtime
|
|
10
12
|
from .resources.sms import Sms
|
|
11
13
|
from .resources.whatsapp import Whatsapp
|
|
12
14
|
from .webhooks import Webhooks
|
|
@@ -51,6 +53,8 @@ class Zapiack:
|
|
|
51
53
|
)
|
|
52
54
|
self.email = Email(http)
|
|
53
55
|
self.sms = Sms(http)
|
|
56
|
+
self.realtime = Realtime(http)
|
|
57
|
+
self.calls = Calls(http)
|
|
54
58
|
self.whatsapp = Whatsapp(http)
|
|
55
59
|
self.push = Push(http)
|
|
56
60
|
self.webhooks = Webhooks()
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, List
|
|
4
|
+
|
|
5
|
+
from .base import Options, Params, Resource, quote
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CallWebhooks(Resource):
|
|
9
|
+
def list(self, options: Options = None) -> Any:
|
|
10
|
+
return self._call("GET", "calls/webhooks", options=options)
|
|
11
|
+
|
|
12
|
+
def create(self, params: Params, options: Options = None) -> Any:
|
|
13
|
+
"""`url` and `events` (a list of room.started, room.ended, participant.joined, participant.left, call.ringing,
|
|
14
|
+
call.accepted, call.ended). The signing `secret` is in this response only: keep it."""
|
|
15
|
+
return self._call("POST", "calls/webhooks", body=dict(params), send=True, options=options)
|
|
16
|
+
|
|
17
|
+
def remove(self, id: str, options: Options = None) -> Any:
|
|
18
|
+
return self._call("DELETE", f"calls/webhooks/{quote(id)}", options=options)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Calls(Resource):
|
|
22
|
+
"""Voice and video. Your server starts calls and mints join tokens; the app holds only the token. Needs an API key with
|
|
23
|
+
the `calls` scope (or no scopes)."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, http) -> None:
|
|
26
|
+
super().__init__(http)
|
|
27
|
+
self.webhooks = CallWebhooks(http)
|
|
28
|
+
|
|
29
|
+
def start(self, params: Params, options: Options = None) -> Any:
|
|
30
|
+
"""Rings one person (`callee`) or several (`callees`, up to 49) and returns the caller's token. `caller` is required;
|
|
31
|
+
`media_kind`-style fields use the API's own names: `mediaKind`, `data`, `push`, `pushAppId`."""
|
|
32
|
+
return self._call("POST", "calls", body=dict(params), send=True, options=options)
|
|
33
|
+
|
|
34
|
+
def get(self, call_id: str, options: Options = None) -> Any:
|
|
35
|
+
return self._call("GET", f"calls/{quote(call_id)}", options=options)
|
|
36
|
+
|
|
37
|
+
def accept(self, call_id: str, params: Params, options: Options = None) -> Any:
|
|
38
|
+
"""Answers for `identity`. Returns that person's token."""
|
|
39
|
+
return self._call("POST", f"calls/{quote(call_id)}/accept", body=dict(params), send=True, options=options)
|
|
40
|
+
|
|
41
|
+
def decline(self, call_id: str, params: Params, options: Options = None) -> Any:
|
|
42
|
+
return self._call("POST", f"calls/{quote(call_id)}/decline", body=dict(params), send=True, options=options)
|
|
43
|
+
|
|
44
|
+
def cancel(self, call_id: str, params: Params, options: Options = None) -> Any:
|
|
45
|
+
"""The caller stops ringing before anyone answers. Only the caller can."""
|
|
46
|
+
return self._call("POST", f"calls/{quote(call_id)}/cancel", body=dict(params), send=True, options=options)
|
|
47
|
+
|
|
48
|
+
def end(self, call_id: str, params: Params, options: Options = None) -> Any:
|
|
49
|
+
return self._call("POST", f"calls/{quote(call_id)}/end", body=dict(params), send=True, options=options)
|
|
50
|
+
|
|
51
|
+
def create_room(self, params: Params, options: Options = None) -> Any:
|
|
52
|
+
"""A room with no ringing: `name`, and optionally `mode` (call, group or live), `maxStage`, `maxAudience`, `region`."""
|
|
53
|
+
return self._call("POST", "calls/rooms", body=dict(params), send=True, options=options)
|
|
54
|
+
|
|
55
|
+
def list_rooms(self, params: Params = {}, options: Options = None) -> Any:
|
|
56
|
+
return self._call("GET", "calls/rooms", query=dict(params), options=options)
|
|
57
|
+
|
|
58
|
+
def get_room(self, room_id: str, options: Options = None) -> Any:
|
|
59
|
+
return self._call("GET", f"calls/rooms/{quote(room_id)}", options=options)
|
|
60
|
+
|
|
61
|
+
def end_room(self, room_id: str, options: Options = None) -> Any:
|
|
62
|
+
"""Ends a room for everyone."""
|
|
63
|
+
return self._call("DELETE", f"calls/rooms/{quote(room_id)}", options=options)
|
|
64
|
+
|
|
65
|
+
def token(self, params: Params, options: Options = None) -> Any:
|
|
66
|
+
"""A join token for one person: `roomId`, `identity`, and optionally `role` (host, speaker, listener), `kinds`,
|
|
67
|
+
`ttlSeconds`, `maxSessionSeconds`."""
|
|
68
|
+
return self._call("POST", "calls/tokens", body=dict(params), send=True, options=options)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, List
|
|
4
|
+
|
|
5
|
+
from .base import Options, Params, Resource, quote
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Realtime(Resource):
|
|
9
|
+
def token(self, params: Params, options: Options = None) -> Any:
|
|
10
|
+
"""A short-lived token for the Realtime SDK in your app: `capabilities` (for example
|
|
11
|
+
{"chat:*": ["subscribe", "publish"]}), and optionally `userId` and `ttlSeconds`."""
|
|
12
|
+
return self._call("POST", "realtime/tokens", body=dict(params), send=True, options=options)
|
|
13
|
+
|
|
14
|
+
def publish(self, channel: str, params: Params = {}, options: Options = None) -> Any:
|
|
15
|
+
"""Sends a message into a channel: `event`, `data`, `from`, and `persist` to keep it in history."""
|
|
16
|
+
return self._call("POST", f"realtime/channels/{quote(channel)}/publish", body=dict(params), send=True, options=options)
|
|
17
|
+
|
|
18
|
+
def publish_batch(self, events: List[Params], options: Options = None) -> Any:
|
|
19
|
+
"""Up to 100 messages, each with a `channel`. One bad message does not fail the rest."""
|
|
20
|
+
return self._call("POST", "realtime/publish/batch", body={"events": [dict(e) for e in events]}, send=True, options=options)
|
|
21
|
+
|
|
22
|
+
def history(self, channel: str, params: Params = {}, options: Options = None) -> Any:
|
|
23
|
+
return self._call("GET", f"realtime/channels/{quote(channel)}/history", query=dict(params), options=options)
|
|
24
|
+
|
|
25
|
+
def presence(self, channel: str, options: Options = None) -> Any:
|
|
26
|
+
return self._call("GET", f"realtime/channels/{quote(channel)}/presence", options=options)
|
|
27
|
+
|
|
28
|
+
def channels(self, params: Params = {}, options: Options = None) -> Any:
|
|
29
|
+
return self._call("GET", "realtime/channels", query=dict(params), options=options)
|
|
30
|
+
|
|
31
|
+
def disconnect_connection(self, connection_id: str, options: Options = None) -> Any:
|
|
32
|
+
return self._call("POST", f"realtime/connections/{quote(connection_id)}/disconnect", send=True, options=options)
|
|
33
|
+
|
|
34
|
+
def disconnect_user(self, user_id: str, options: Options = None) -> Any:
|
|
35
|
+
"""Closes every connection a person has, for example when they sign out everywhere."""
|
|
36
|
+
return self._call("POST", f"realtime/users/{quote(user_id)}/disconnect", send=True, options=options)
|
|
@@ -15,8 +15,10 @@ src/zapiack.egg-info/dependency_links.txt
|
|
|
15
15
|
src/zapiack.egg-info/top_level.txt
|
|
16
16
|
src/zapiack/resources/__init__.py
|
|
17
17
|
src/zapiack/resources/base.py
|
|
18
|
+
src/zapiack/resources/calls.py
|
|
18
19
|
src/zapiack/resources/email.py
|
|
19
20
|
src/zapiack/resources/push.py
|
|
21
|
+
src/zapiack/resources/realtime.py
|
|
20
22
|
src/zapiack/resources/sms.py
|
|
21
23
|
src/zapiack/resources/whatsapp.py
|
|
22
24
|
tests/test_http.py
|
|
@@ -11,7 +11,7 @@ class Headers(unittest.TestCase):
|
|
|
11
11
|
z.email.get("e1")
|
|
12
12
|
h = t.calls[0].headers
|
|
13
13
|
self.assertEqual(h["Authorization"], "Bearer zpk_abc12345_secret")
|
|
14
|
-
self.assertTrue(h["User-Agent"].startswith("zapiack-python/0.
|
|
14
|
+
self.assertTrue(h["User-Agent"].startswith("zapiack-python/0.2.0 python/"))
|
|
15
15
|
self.assertTrue(h["X-Request-Id"])
|
|
16
16
|
self.assertEqual(t.calls[0].url, "https://api.zapiack.com/v1/email/e1")
|
|
17
17
|
|
|
@@ -123,6 +123,30 @@ ROUTES = [
|
|
|
123
123
|
("push.webhooks.create", lambda z: z.push.webhooks.create({"url": "https://x.test/h", "events": ["push.sent"]}), "POST", "push/webhooks", {"url": "https://x.test/h", "events": ["push.sent"]}),
|
|
124
124
|
("push.webhooks.rotate", lambda z: z.push.webhooks.rotate_secret("w1"), "POST", "push/webhooks/w1/secret", None),
|
|
125
125
|
("push.webhooks.test", lambda z: z.push.webhooks.test("w1"), "POST", "push/webhooks/w1/test", None),
|
|
126
|
+
# calls
|
|
127
|
+
("calls.start", lambda z: z.calls.start({"caller": "ada", "callees": ["bola", "lee"], "mediaKind": "video"}), "POST", "calls", {"caller": "ada", "callees": ["bola", "lee"], "mediaKind": "video"}),
|
|
128
|
+
("calls.get", lambda z: z.calls.get("c 1"), "GET", "calls/c%201", None),
|
|
129
|
+
("calls.accept", lambda z: z.calls.accept("c1", {"identity": "bola"}), "POST", "calls/c1/accept", {"identity": "bola"}),
|
|
130
|
+
("calls.decline", lambda z: z.calls.decline("c1", {"identity": "bola"}), "POST", "calls/c1/decline", {"identity": "bola"}),
|
|
131
|
+
("calls.cancel", lambda z: z.calls.cancel("c1", {"identity": "ada"}), "POST", "calls/c1/cancel", {"identity": "ada"}),
|
|
132
|
+
("calls.end", lambda z: z.calls.end("c1", {"identity": "ada"}), "POST", "calls/c1/end", {"identity": "ada"}),
|
|
133
|
+
("calls.create_room", lambda z: z.calls.create_room({"name": "Standup"}), "POST", "calls/rooms", {"name": "Standup"}),
|
|
134
|
+
("calls.list_rooms", lambda z: z.calls.list_rooms({"status": "ACTIVE"}), "GET", "calls/rooms?status=ACTIVE", None),
|
|
135
|
+
("calls.get_room", lambda z: z.calls.get_room("r1"), "GET", "calls/rooms/r1", None),
|
|
136
|
+
("calls.end_room", lambda z: z.calls.end_room("r1"), "DELETE", "calls/rooms/r1", None),
|
|
137
|
+
("calls.token", lambda z: z.calls.token({"roomId": "r1", "identity": "ada"}), "POST", "calls/tokens", {"roomId": "r1", "identity": "ada"}),
|
|
138
|
+
("calls.webhooks.list", lambda z: z.calls.webhooks.list(), "GET", "calls/webhooks", None),
|
|
139
|
+
("calls.webhooks.create", lambda z: z.calls.webhooks.create({"url": "https://x.test/h", "events": ["call.ended"]}), "POST", "calls/webhooks", {"url": "https://x.test/h", "events": ["call.ended"]}),
|
|
140
|
+
("calls.webhooks.remove", lambda z: z.calls.webhooks.remove("w1"), "DELETE", "calls/webhooks/w1", None),
|
|
141
|
+
# realtime
|
|
142
|
+
("realtime.token", lambda z: z.realtime.token({"capabilities": {"chat:*": ["subscribe"]}}), "POST", "realtime/tokens", {"capabilities": {"chat:*": ["subscribe"]}}),
|
|
143
|
+
("realtime.publish", lambda z: z.realtime.publish("chat:1", {"data": 1}), "POST", "realtime/channels/chat%3A1/publish", {"data": 1}),
|
|
144
|
+
("realtime.publish_batch", lambda z: z.realtime.publish_batch([{"channel": "a"}]), "POST", "realtime/publish/batch", {"events": [{"channel": "a"}]}),
|
|
145
|
+
("realtime.history", lambda z: z.realtime.history("chat:1", {"limit": 20}), "GET", "realtime/channels/chat%3A1/history?limit=20", None),
|
|
146
|
+
("realtime.presence", lambda z: z.realtime.presence("chat:1"), "GET", "realtime/channels/chat%3A1/presence", None),
|
|
147
|
+
("realtime.channels", lambda z: z.realtime.channels({"search": "c"}), "GET", "realtime/channels?search=c", None),
|
|
148
|
+
("realtime.disconnect_connection", lambda z: z.realtime.disconnect_connection("k1"), "POST", "realtime/connections/k1/disconnect", None),
|
|
149
|
+
("realtime.disconnect_user", lambda z: z.realtime.disconnect_user("ada"), "POST", "realtime/users/ada/disconnect", None),
|
|
126
150
|
]
|
|
127
151
|
|
|
128
152
|
LIST_SHAPES = {"data": [], "messages": [], "deliveries": [], "devices": []}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.1.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|