syncteams-sdk 0.2.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.

Potentially problematic release.


This version of syncteams-sdk might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SyncTeams
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.
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.2
2
+ Name: syncteams-sdk
3
+ Version: 0.2.0
4
+ Summary: Python client for the SyncTeams Workflow API
5
+ Author-email: SyncTeams <support@syncteams.studio>
6
+ Project-URL: Homepage, https://develop.syncteams.studio
7
+ Project-URL: Repository, https://github.com/syncteamsstudio/python-sdk.git
8
+ Project-URL: Documentation, https://develop.syncteams.studio
9
+ Keywords: workflow,automation,syncteams,sdk
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests>=2.31.0
24
+ Requires-Dist: typing-extensions>=4.8.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.4; extra == "dev"
27
+ Requires-Dist: responses>=0.25.0; extra == "dev"
28
+ Requires-Dist: coverage>=7.3; extra == "dev"
29
+
30
+ # SyncTeams Workflow SDK (Python)
31
+
32
+ A Python client for the SyncTeams Workflow API. Mirrors the capabilities of the JavaScript SDK, offering convenient helpers to execute workflows, monitor task status, and manage approval flows.
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install syncteams-sdk
40
+ ```
41
+
42
+ **Requirements:** Python 3.9 or newer
43
+
44
+ ---
45
+
46
+ ## Quick Start
47
+
48
+ ```python
49
+ from syncteams_sdk import WorkflowClient
50
+
51
+ client = WorkflowClient(api_key="YOUR_API_KEY")
52
+
53
+ # Execute a workflow
54
+ result = client.execute_workflow(
55
+ workflow_id="your_workflow_id",
56
+ input={"email": "user@example.com"},
57
+ unique_id="customer-123",
58
+ )
59
+
60
+ task_id = result["taskId"]
61
+
62
+ # Wait for completion
63
+ final_status = client.wait_for_completion(
64
+ task_id,
65
+ poll_interval_ms=2_000,
66
+ on_update=lambda status: print(f"Status: {status['status']}")
67
+ )
68
+
69
+ if final_status["status"] == "COMPLETED":
70
+ print("Workflow completed successfully!")
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Configuration
76
+
77
+ | Option | Required | Default | Description |
78
+ | --- | --- | --- | --- |
79
+ | `api_key` | ✅ | – | Your SyncTeams API key |
80
+ | `base_url` | ❌ | `https://develop.api.syncteams.studio` | API base URL |
81
+ | `timeout_ms` | ❌ | `30000` | Request timeout in milliseconds |
82
+ | `retry` | ❌ | See below | Retry configuration for failed requests |
83
+ | `default_headers` | ❌ | `{}` | Extra headers merged into every request |
84
+ | `user_agent_suffix` | ❌ | – | Extra token appended to the default User-Agent |
85
+
86
+ ### Retry Configuration
87
+
88
+ By default, the SDK retries transient failures with exponential backoff:
89
+ - Maximum attempts: 3
90
+ - Initial delay: 1 second
91
+ - Backoff factor: 2x
92
+ - Maximum delay: 30 seconds
93
+ - Retries on: 408, 425, 429, and all 5xx responses
94
+
95
+ You can override any subset of these values when constructing the client.
96
+
97
+ ---
98
+
99
+ ## API overview
100
+
101
+ ### `execute_workflow(workflow_id, input, unique_id=None)`
102
+
103
+ Starts a workflow execution.
104
+
105
+ ```python
106
+ response = client.execute_workflow(
107
+ workflow_id="your_workflow_id",
108
+ input={"customer_id": "cust-123"},
109
+ )
110
+
111
+ print(response["taskId"], response["status"])
112
+ ```
113
+
114
+ Returns the `taskId` and initial status.
115
+
116
+ ### `get_task_status(task_id)`
117
+
118
+ Fetches the latest status and the filtered event log for a task.
119
+
120
+ ```python
121
+ status = client.get_task_status(task_id)
122
+ print(status["status"], len(status.get("eventLogs", [])))
123
+ ```
124
+
125
+ ### `continue_task(task_id, decision, message=None)`
126
+
127
+ Resumes a waiting workflow after an approval decision.
128
+
129
+ ```python
130
+ client.continue_task(task_id=task_id, decision="APPROVE")
131
+
132
+ client.continue_task(
133
+ task_id=task_id,
134
+ decision="REJECT",
135
+ message="Missing documentation",
136
+ )
137
+ ```
138
+
139
+ When `decision` is `"REJECT"`, `message` is required.
140
+
141
+ ### `wait_for_completion(task_id, *, poll_interval_ms=2000, max_wait_time_ms=600000, on_update=None, exit_on_waiting=False, terminal_statuses=None, stop_event=None)`
142
+
143
+ Polls a task until it reaches a terminal status (`COMPLETED`, `FAILED`, or `CANCELED`).
144
+
145
+ ```python
146
+ final_status = client.wait_for_completion(
147
+ task_id,
148
+ poll_interval_ms=1000,
149
+ on_update=lambda payload: print("Status:", payload["status"]),
150
+ )
151
+ ```
152
+
153
+ ### `execute_and_wait(workflow_id, input, **options)`
154
+
155
+ Convenience method that starts a workflow and optionally handles approvals via `on_waiting`.
156
+
157
+ ```python
158
+ def handle_waiting(status):
159
+ # Perform approval logic
160
+ client.continue_task(task_id=status["taskId"], decision="APPROVE")
161
+ return True
162
+
163
+ result = client.execute_and_wait(
164
+ workflow_id="wf-123",
165
+ input={"amount": 500},
166
+ on_waiting=handle_waiting,
167
+ )
168
+ ```
169
+
170
+ If `on_waiting` returns `False`, polling stops and the SDK returns the current status (even if still waiting).
171
+
172
+ ---
173
+
174
+ ## Error Handling
175
+
176
+ The SDK raises `WorkflowAPIError` for API failures. It exposes the HTTP status, headers, response payload, and request metadata to simplify debugging.
177
+
178
+ ```python
179
+ from syncteams_sdk import WorkflowAPIError
180
+
181
+ try:
182
+ client.execute_workflow(workflow_id="invalid", input={})
183
+ except WorkflowAPIError as error:
184
+ print("API error:", error.status, error.data)
185
+ ```
186
+
187
+ Transient errors (timeouts, rate limits, server errors) are automatically retried according to the configured policy.
188
+
189
+ ---
190
+
191
+ ## Webhooks
192
+
193
+ You can receive workflow updates via webhooks instead of polling:
194
+
195
+ ```python
196
+ from flask import Flask, request
197
+ from syncteams_sdk import WebhookEventPayload
198
+
199
+ app = Flask(__name__)
200
+
201
+ @app.post("/webhooks/syncteams")
202
+ def handle_webhook():
203
+ payload: WebhookEventPayload = request.get_json(force=True)
204
+ print("Task", payload["taskId"], "status:", payload["status"])
205
+ return ("", 200)
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Development
211
+
212
+ Install dependencies and run tests:
213
+
214
+ ```bash
215
+ pip install -e .[dev]
216
+ pytest
217
+ ```
218
+
219
+ ---
220
+
221
+ ## License
222
+
223
+ MIT
@@ -0,0 +1,5 @@
1
+ syncteams_sdk-0.2.0.dist-info/LICENSE,sha256=HpkUQoEdxz-kqHWYeuZIDPBruqySo3TQ_Cx9XHPqmiI,1066
2
+ syncteams_sdk-0.2.0.dist-info/METADATA,sha256=fcXCOIh-TG6C8H5B9lZMuzVD644HI0MJJXvsCFXdpqU,5871
3
+ syncteams_sdk-0.2.0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
4
+ syncteams_sdk-0.2.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ syncteams_sdk-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (76.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+