sapancal 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.
- sapancal-0.2.0/.gitignore +5 -0
- sapancal-0.2.0/LICENSE +21 -0
- sapancal-0.2.0/PKG-INFO +189 -0
- sapancal-0.2.0/README.md +172 -0
- sapancal-0.2.0/pyproject.toml +37 -0
- sapancal-0.2.0/src/sapancal/__init__.py +66 -0
- sapancal-0.2.0/src/sapancal/_client.py +605 -0
- sapancal-0.2.0/src/sapancal/_errors.py +52 -0
- sapancal-0.2.0/src/sapancal/_types.py +283 -0
- sapancal-0.2.0/src/sapancal/_version.py +1 -0
- sapancal-0.2.0/src/sapancal/_webhooks.py +116 -0
- sapancal-0.2.0/src/sapancal/py.typed +0 -0
- sapancal-0.2.0/tests/__init__.py +0 -0
- sapancal-0.2.0/tests/conftest.py +62 -0
- sapancal-0.2.0/tests/test_client.py +151 -0
- sapancal-0.2.0/tests/test_contract.py +68 -0
- sapancal-0.2.0/tests/test_e2e.py +71 -0
- sapancal-0.2.0/tests/test_webhooks.py +78 -0
- sapancal-0.2.0/uv.lock +426 -0
sapancal-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sapan Labs Pty Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
sapancal-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sapancal
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The SapanCal API client for Python: connect Google and Microsoft calendars, find availability, write events, verify webhooks.
|
|
5
|
+
Project-URL: Homepage, https://sapancal.com
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: availability,calendar,free busy,google calendar,microsoft outlook,sapancal,scheduling
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Framework :: AsyncIO
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: httpx<1,>=0.27
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# SapanCal for Python
|
|
19
|
+
|
|
20
|
+
The official client for the [SapanCal](https://sapancal.com) API: connect your users' Google and Microsoft calendars, find when they're free, and write events, from one API.
|
|
21
|
+
|
|
22
|
+
- Sync and asyncio clients
|
|
23
|
+
- Fully typed: responses are `TypedDict`s generated from the API's OpenAPI document
|
|
24
|
+
- Retries rate limits and provider hiccups for you
|
|
25
|
+
- Webhook signature verification built in
|
|
26
|
+
- One dependency (`httpx`), Python 3.11+
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install sapancal
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quickstart
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from sapancal import SapanCal
|
|
36
|
+
|
|
37
|
+
client = SapanCal() # reads SAPANCAL_API_KEY
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Your API key is in the console under **Application → API keys**. It already says which region your application lives in, so there's nothing else to configure.
|
|
41
|
+
|
|
42
|
+
### 1. Connect a calendar
|
|
43
|
+
|
|
44
|
+
Create a connect session for one of your users and send them to its `url`:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
session = client.connect_sessions.create(
|
|
48
|
+
user_id="user_123", # your own id for the user
|
|
49
|
+
redirect_uri="https://app.example.com/calendar/connected",
|
|
50
|
+
)
|
|
51
|
+
return redirect(session["url"])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
They sign in to Google or Microsoft and come back to your `redirect_uri` with `connect_session_id` and `status` in the query string:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
# GET /calendar/connected?connect_session_id=cs_...&status=success
|
|
58
|
+
session = client.connect_sessions.get(request.args["connect_session_id"])
|
|
59
|
+
if session["status"] == "completed":
|
|
60
|
+
print("Connected", session["connection"]["email"])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 2. Find a time
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from datetime import datetime
|
|
67
|
+
from zoneinfo import ZoneInfo
|
|
68
|
+
|
|
69
|
+
sydney = ZoneInfo("Australia/Sydney")
|
|
70
|
+
result = client.availability.query(
|
|
71
|
+
participants=[{"user_id": "user_123"}, {"user_id": "user_456"}],
|
|
72
|
+
periods=[{"start": datetime(2026, 11, 2, 9, tzinfo=sydney), "end": datetime(2026, 11, 2, 17, tzinfo=sydney)}],
|
|
73
|
+
slot_duration_minutes=30,
|
|
74
|
+
)
|
|
75
|
+
for slot in result["slots"]:
|
|
76
|
+
print(slot["start"], slot["user_ids"])
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`start` and `end` take a timezone-aware `datetime` or an ISO 8601 string. For raw busy blocks instead of slots, use `client.free_busy.query(user_ids=[...], start=..., end=...)`.
|
|
80
|
+
|
|
81
|
+
### 3. Book it
|
|
82
|
+
|
|
83
|
+
Events are keyed by your own id, so the same call creates and later updates the event, and a retry never makes a duplicate:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
slot = result["slots"][0]
|
|
87
|
+
client.events.upsert("user_123", "booking_789", summary="Intro call", start=slot["start"], end=slot["end"], time_zone="Australia/Sydney")
|
|
88
|
+
|
|
89
|
+
client.events.delete("user_123", "booking_789")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 4. Handle webhooks
|
|
93
|
+
|
|
94
|
+
SapanCal tells you when a connection is created, needs relinking or is revoked, and when a calendar changes. Verify the signature against the **raw** request body:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from sapancal import WebhookVerificationError
|
|
98
|
+
|
|
99
|
+
# Flask
|
|
100
|
+
@app.post("/webhooks/sapancal")
|
|
101
|
+
def sapancal_webhook():
|
|
102
|
+
try:
|
|
103
|
+
event = client.webhooks.verify(request.get_data(), request.headers) # secret from SAPANCAL_WEBHOOK_SECRET
|
|
104
|
+
except WebhookVerificationError:
|
|
105
|
+
return "", 400
|
|
106
|
+
|
|
107
|
+
if event["type"] == "connection.relink_required":
|
|
108
|
+
ask_user_to_reconnect(event["data"]["user_id"], event["data"]["connection_id"])
|
|
109
|
+
elif event["type"] == "calendar.changed":
|
|
110
|
+
resync(event["data"]["user_id"], event["data"]["calendar_id"])
|
|
111
|
+
return "", 204
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
In Django pass `request.body` and `request.headers`; in FastAPI, `await request.body()` and `request.headers`. Verification fails if the signature is missing, wrong or older than five minutes. Deliveries are retried, so use `event["id"]` to skip ones you've already handled. During a signing-secret rotation both the old and new secret are accepted.
|
|
115
|
+
|
|
116
|
+
To test your handler, sign your own payload with `sapancal.sign_webhook(body, "whsec_test")` and send it as the `SapanCal-Signature` header.
|
|
117
|
+
|
|
118
|
+
## Async
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from sapancal import AsyncSapanCal
|
|
122
|
+
|
|
123
|
+
async with AsyncSapanCal() as client:
|
|
124
|
+
user = await client.users.get("user_123")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Every method is the same, awaited.
|
|
128
|
+
|
|
129
|
+
## All methods
|
|
130
|
+
|
|
131
|
+
| Method | API |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `connect_sessions.create(user_id=, redirect_uri=, provider=, connection_id=)` | `POST /connect_sessions` |
|
|
134
|
+
| `connect_sessions.get(id)` | `GET /connect_sessions/{id}` |
|
|
135
|
+
| `users.get(user_id)` | `GET /users/{user_id}` |
|
|
136
|
+
| `users.update(user_id, default_connection_id=)` | `PATCH /users/{user_id}` |
|
|
137
|
+
| `users.delete(user_id)` | `DELETE /users/{user_id}` |
|
|
138
|
+
| `connections.get(id)` | `GET /connections/{id}` |
|
|
139
|
+
| `connections.delete(id)` | `DELETE /connections/{id}` |
|
|
140
|
+
| `connections.list_calendars(id)` | `GET /connections/{id}/calendars` |
|
|
141
|
+
| `free_busy.query(user_ids=, start=, end=, calendar_ids=)` | `POST /free_busy` |
|
|
142
|
+
| `availability.query(participants=, periods=, slot_duration_minutes=, ...)` | `POST /availability` |
|
|
143
|
+
| `events.upsert(user_id, event_id, summary=, start=, end=, ...)` | `PUT /users/{user_id}/events/{event_id}` |
|
|
144
|
+
| `events.delete(user_id, event_id)` | `DELETE /users/{user_id}/events/{event_id}` |
|
|
145
|
+
| `webhooks.verify(payload, headers, secret=)` | checks a webhook locally |
|
|
146
|
+
|
|
147
|
+
Arguments and response keys use the API's names, so the [API reference](https://api.sapancal.com/openapi.json) applies as written.
|
|
148
|
+
|
|
149
|
+
## Errors
|
|
150
|
+
|
|
151
|
+
API errors raise `SapanCalApiError`. Branch on `code`, which is stable; the message is for people.
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from sapancal import SapanCalApiError
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
client.events.upsert(user_id, booking_id, summary="Intro call", start=start, end=end)
|
|
158
|
+
except SapanCalApiError as err:
|
|
159
|
+
if err.code == "relink_required":
|
|
160
|
+
# The user revoked access or changed their password: send them through a new connect
|
|
161
|
+
# session with connection_id to relink.
|
|
162
|
+
...
|
|
163
|
+
raise
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`SapanCalApiError` has `status`, `code`, `message`, `request_id` (quote it to support), `details` (validation issues) and `retry_after`. Network failures and timeouts raise `SapanCalConnectionError`. Both extend `SapanCalError`.
|
|
167
|
+
|
|
168
|
+
## Retries and timeouts
|
|
169
|
+
|
|
170
|
+
Network errors, `429` and `502`–`504` are retried twice with exponential backoff, waiting as long as the API's `Retry-After` asks (up to 60 seconds; longer waits raise instead). Each attempt times out after 30 seconds.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
client = SapanCal(max_retries=4, timeout=10)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
| Argument | Environment variable | Default |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `api_key` | `SAPANCAL_API_KEY` | required |
|
|
181
|
+
| `webhook_secret` | `SAPANCAL_WEBHOOK_SECRET` | none |
|
|
182
|
+
| `base_url` | `SAPANCAL_BASE_URL` | `https://api.sapancal.com/{region}/v1`, region from the key |
|
|
183
|
+
| `timeout` | | `30` seconds |
|
|
184
|
+
| `max_retries` | | `2` |
|
|
185
|
+
| `http_client` | | a new `httpx.Client` / `httpx.AsyncClient` |
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
MIT
|
sapancal-0.2.0/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# SapanCal for Python
|
|
2
|
+
|
|
3
|
+
The official client for the [SapanCal](https://sapancal.com) API: connect your users' Google and Microsoft calendars, find when they're free, and write events, from one API.
|
|
4
|
+
|
|
5
|
+
- Sync and asyncio clients
|
|
6
|
+
- Fully typed: responses are `TypedDict`s generated from the API's OpenAPI document
|
|
7
|
+
- Retries rate limits and provider hiccups for you
|
|
8
|
+
- Webhook signature verification built in
|
|
9
|
+
- One dependency (`httpx`), Python 3.11+
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install sapancal
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from sapancal import SapanCal
|
|
19
|
+
|
|
20
|
+
client = SapanCal() # reads SAPANCAL_API_KEY
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Your API key is in the console under **Application → API keys**. It already says which region your application lives in, so there's nothing else to configure.
|
|
24
|
+
|
|
25
|
+
### 1. Connect a calendar
|
|
26
|
+
|
|
27
|
+
Create a connect session for one of your users and send them to its `url`:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
session = client.connect_sessions.create(
|
|
31
|
+
user_id="user_123", # your own id for the user
|
|
32
|
+
redirect_uri="https://app.example.com/calendar/connected",
|
|
33
|
+
)
|
|
34
|
+
return redirect(session["url"])
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
They sign in to Google or Microsoft and come back to your `redirect_uri` with `connect_session_id` and `status` in the query string:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
# GET /calendar/connected?connect_session_id=cs_...&status=success
|
|
41
|
+
session = client.connect_sessions.get(request.args["connect_session_id"])
|
|
42
|
+
if session["status"] == "completed":
|
|
43
|
+
print("Connected", session["connection"]["email"])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Find a time
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from datetime import datetime
|
|
50
|
+
from zoneinfo import ZoneInfo
|
|
51
|
+
|
|
52
|
+
sydney = ZoneInfo("Australia/Sydney")
|
|
53
|
+
result = client.availability.query(
|
|
54
|
+
participants=[{"user_id": "user_123"}, {"user_id": "user_456"}],
|
|
55
|
+
periods=[{"start": datetime(2026, 11, 2, 9, tzinfo=sydney), "end": datetime(2026, 11, 2, 17, tzinfo=sydney)}],
|
|
56
|
+
slot_duration_minutes=30,
|
|
57
|
+
)
|
|
58
|
+
for slot in result["slots"]:
|
|
59
|
+
print(slot["start"], slot["user_ids"])
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`start` and `end` take a timezone-aware `datetime` or an ISO 8601 string. For raw busy blocks instead of slots, use `client.free_busy.query(user_ids=[...], start=..., end=...)`.
|
|
63
|
+
|
|
64
|
+
### 3. Book it
|
|
65
|
+
|
|
66
|
+
Events are keyed by your own id, so the same call creates and later updates the event, and a retry never makes a duplicate:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
slot = result["slots"][0]
|
|
70
|
+
client.events.upsert("user_123", "booking_789", summary="Intro call", start=slot["start"], end=slot["end"], time_zone="Australia/Sydney")
|
|
71
|
+
|
|
72
|
+
client.events.delete("user_123", "booking_789")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Handle webhooks
|
|
76
|
+
|
|
77
|
+
SapanCal tells you when a connection is created, needs relinking or is revoked, and when a calendar changes. Verify the signature against the **raw** request body:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from sapancal import WebhookVerificationError
|
|
81
|
+
|
|
82
|
+
# Flask
|
|
83
|
+
@app.post("/webhooks/sapancal")
|
|
84
|
+
def sapancal_webhook():
|
|
85
|
+
try:
|
|
86
|
+
event = client.webhooks.verify(request.get_data(), request.headers) # secret from SAPANCAL_WEBHOOK_SECRET
|
|
87
|
+
except WebhookVerificationError:
|
|
88
|
+
return "", 400
|
|
89
|
+
|
|
90
|
+
if event["type"] == "connection.relink_required":
|
|
91
|
+
ask_user_to_reconnect(event["data"]["user_id"], event["data"]["connection_id"])
|
|
92
|
+
elif event["type"] == "calendar.changed":
|
|
93
|
+
resync(event["data"]["user_id"], event["data"]["calendar_id"])
|
|
94
|
+
return "", 204
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
In Django pass `request.body` and `request.headers`; in FastAPI, `await request.body()` and `request.headers`. Verification fails if the signature is missing, wrong or older than five minutes. Deliveries are retried, so use `event["id"]` to skip ones you've already handled. During a signing-secret rotation both the old and new secret are accepted.
|
|
98
|
+
|
|
99
|
+
To test your handler, sign your own payload with `sapancal.sign_webhook(body, "whsec_test")` and send it as the `SapanCal-Signature` header.
|
|
100
|
+
|
|
101
|
+
## Async
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from sapancal import AsyncSapanCal
|
|
105
|
+
|
|
106
|
+
async with AsyncSapanCal() as client:
|
|
107
|
+
user = await client.users.get("user_123")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Every method is the same, awaited.
|
|
111
|
+
|
|
112
|
+
## All methods
|
|
113
|
+
|
|
114
|
+
| Method | API |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `connect_sessions.create(user_id=, redirect_uri=, provider=, connection_id=)` | `POST /connect_sessions` |
|
|
117
|
+
| `connect_sessions.get(id)` | `GET /connect_sessions/{id}` |
|
|
118
|
+
| `users.get(user_id)` | `GET /users/{user_id}` |
|
|
119
|
+
| `users.update(user_id, default_connection_id=)` | `PATCH /users/{user_id}` |
|
|
120
|
+
| `users.delete(user_id)` | `DELETE /users/{user_id}` |
|
|
121
|
+
| `connections.get(id)` | `GET /connections/{id}` |
|
|
122
|
+
| `connections.delete(id)` | `DELETE /connections/{id}` |
|
|
123
|
+
| `connections.list_calendars(id)` | `GET /connections/{id}/calendars` |
|
|
124
|
+
| `free_busy.query(user_ids=, start=, end=, calendar_ids=)` | `POST /free_busy` |
|
|
125
|
+
| `availability.query(participants=, periods=, slot_duration_minutes=, ...)` | `POST /availability` |
|
|
126
|
+
| `events.upsert(user_id, event_id, summary=, start=, end=, ...)` | `PUT /users/{user_id}/events/{event_id}` |
|
|
127
|
+
| `events.delete(user_id, event_id)` | `DELETE /users/{user_id}/events/{event_id}` |
|
|
128
|
+
| `webhooks.verify(payload, headers, secret=)` | checks a webhook locally |
|
|
129
|
+
|
|
130
|
+
Arguments and response keys use the API's names, so the [API reference](https://api.sapancal.com/openapi.json) applies as written.
|
|
131
|
+
|
|
132
|
+
## Errors
|
|
133
|
+
|
|
134
|
+
API errors raise `SapanCalApiError`. Branch on `code`, which is stable; the message is for people.
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from sapancal import SapanCalApiError
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
client.events.upsert(user_id, booking_id, summary="Intro call", start=start, end=end)
|
|
141
|
+
except SapanCalApiError as err:
|
|
142
|
+
if err.code == "relink_required":
|
|
143
|
+
# The user revoked access or changed their password: send them through a new connect
|
|
144
|
+
# session with connection_id to relink.
|
|
145
|
+
...
|
|
146
|
+
raise
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`SapanCalApiError` has `status`, `code`, `message`, `request_id` (quote it to support), `details` (validation issues) and `retry_after`. Network failures and timeouts raise `SapanCalConnectionError`. Both extend `SapanCalError`.
|
|
150
|
+
|
|
151
|
+
## Retries and timeouts
|
|
152
|
+
|
|
153
|
+
Network errors, `429` and `502`–`504` are retried twice with exponential backoff, waiting as long as the API's `Retry-After` asks (up to 60 seconds; longer waits raise instead). Each attempt times out after 30 seconds.
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
client = SapanCal(max_retries=4, timeout=10)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Configuration
|
|
160
|
+
|
|
161
|
+
| Argument | Environment variable | Default |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `api_key` | `SAPANCAL_API_KEY` | required |
|
|
164
|
+
| `webhook_secret` | `SAPANCAL_WEBHOOK_SECRET` | none |
|
|
165
|
+
| `base_url` | `SAPANCAL_BASE_URL` | `https://api.sapancal.com/{region}/v1`, region from the key |
|
|
166
|
+
| `timeout` | | `30` seconds |
|
|
167
|
+
| `max_retries` | | `2` |
|
|
168
|
+
| `http_client` | | a new `httpx.Client` / `httpx.AsyncClient` |
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sapancal"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "The SapanCal API client for Python: connect Google and Microsoft calendars, find availability, write events, verify webhooks."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = ["httpx>=0.27,<1"]
|
|
10
|
+
keywords = ["sapancal", "calendar", "google calendar", "microsoft outlook", "availability", "scheduling", "free busy"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 4 - Beta",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://sapancal.com"
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
dev = ["pytest>=8", "mypy>=1.13"]
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["hatchling>=1.27"]
|
|
27
|
+
build-backend = "hatchling.build"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.wheel]
|
|
30
|
+
packages = ["src/sapancal"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
testpaths = ["tests"]
|
|
34
|
+
|
|
35
|
+
[tool.mypy]
|
|
36
|
+
strict = true
|
|
37
|
+
files = ["src"]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""The SapanCal API client: connect Google and Microsoft calendars, find availability, write events, verify webhooks."""
|
|
2
|
+
|
|
3
|
+
from ._client import AsyncSapanCal, SapanCal, DateTimeInput
|
|
4
|
+
from ._errors import SapanCalApiError, SapanCalConnectionError, SapanCalError, WebhookVerificationError
|
|
5
|
+
from ._types import (
|
|
6
|
+
AvailabilityResponse,
|
|
7
|
+
AvailabilitySlot,
|
|
8
|
+
Calendar,
|
|
9
|
+
CalendarChangedEvent,
|
|
10
|
+
CalendarChangedWebhookData,
|
|
11
|
+
Connection,
|
|
12
|
+
ConnectionCreatedEvent,
|
|
13
|
+
ConnectionRelinkedEvent,
|
|
14
|
+
ConnectionRelinkRequiredEvent,
|
|
15
|
+
ConnectionRevokedEvent,
|
|
16
|
+
ConnectionWebhookData,
|
|
17
|
+
ConnectSession,
|
|
18
|
+
Event,
|
|
19
|
+
FreeBusyResponse,
|
|
20
|
+
ParticipantError,
|
|
21
|
+
TimeInterval,
|
|
22
|
+
User,
|
|
23
|
+
)
|
|
24
|
+
from ._version import __version__
|
|
25
|
+
from ._webhooks import (
|
|
26
|
+
DEFAULT_WEBHOOK_TOLERANCE,
|
|
27
|
+
WEBHOOK_EVENT_ID_HEADER,
|
|
28
|
+
WEBHOOK_SIGNATURE_HEADER,
|
|
29
|
+
WebhookEvent,
|
|
30
|
+
sign_webhook,
|
|
31
|
+
verify_webhook,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"AsyncSapanCal",
|
|
36
|
+
"AvailabilityResponse",
|
|
37
|
+
"AvailabilitySlot",
|
|
38
|
+
"SapanCal",
|
|
39
|
+
"SapanCalApiError",
|
|
40
|
+
"SapanCalConnectionError",
|
|
41
|
+
"SapanCalError",
|
|
42
|
+
"Calendar",
|
|
43
|
+
"CalendarChangedEvent",
|
|
44
|
+
"CalendarChangedWebhookData",
|
|
45
|
+
"Connection",
|
|
46
|
+
"ConnectionCreatedEvent",
|
|
47
|
+
"ConnectionRelinkedEvent",
|
|
48
|
+
"ConnectionRelinkRequiredEvent",
|
|
49
|
+
"ConnectionRevokedEvent",
|
|
50
|
+
"ConnectionWebhookData",
|
|
51
|
+
"ConnectSession",
|
|
52
|
+
"DEFAULT_WEBHOOK_TOLERANCE",
|
|
53
|
+
"DateTimeInput",
|
|
54
|
+
"Event",
|
|
55
|
+
"FreeBusyResponse",
|
|
56
|
+
"ParticipantError",
|
|
57
|
+
"TimeInterval",
|
|
58
|
+
"User",
|
|
59
|
+
"WEBHOOK_EVENT_ID_HEADER",
|
|
60
|
+
"WEBHOOK_SIGNATURE_HEADER",
|
|
61
|
+
"WebhookEvent",
|
|
62
|
+
"WebhookVerificationError",
|
|
63
|
+
"__version__",
|
|
64
|
+
"sign_webhook",
|
|
65
|
+
"verify_webhook",
|
|
66
|
+
]
|