oriacall 0.1.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.
- oriacall-0.1.0/.gitignore +9 -0
- oriacall-0.1.0/LICENSE +21 -0
- oriacall-0.1.0/PKG-INFO +294 -0
- oriacall-0.1.0/README.md +266 -0
- oriacall-0.1.0/pyproject.toml +51 -0
- oriacall-0.1.0/src/oriacall/__init__.py +11 -0
- oriacall-0.1.0/src/oriacall/client.py +552 -0
- oriacall-0.1.0/src/oriacall/errors.py +28 -0
- oriacall-0.1.0/src/oriacall/response.py +11 -0
- oriacall-0.1.0/tests/test_client.py +171 -0
oriacall-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oriacall
|
|
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.
|
oriacall-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oriacall
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Oriacall Developer API.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Karim-Chrif/oriacall-python-sdk#readme
|
|
6
|
+
Project-URL: Repository, https://github.com/Karim-Chrif/oriacall-python-sdk
|
|
7
|
+
Project-URL: Issues, https://github.com/Karim-Chrif/oriacall-python-sdk/issues
|
|
8
|
+
Author: Oriacall
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,oriacall,python,sdk
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
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: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Requires-Dist: requests>=2.31.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: build>=1.2.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# oriacall
|
|
30
|
+
|
|
31
|
+
Python SDK for the Oriacall Developer API.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install oriacall
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Requirements:
|
|
40
|
+
|
|
41
|
+
- Python 3.9 or newer.
|
|
42
|
+
- An Oriacall Developer API client ID and secret.
|
|
43
|
+
- Server-side usage only. Do not expose `client_secret` in browser or client app code.
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import os
|
|
49
|
+
|
|
50
|
+
from oriacall import Oriacall
|
|
51
|
+
|
|
52
|
+
oriacall = Oriacall(
|
|
53
|
+
client_id=os.environ["ORIACALL_CLIENT_ID"],
|
|
54
|
+
client_secret=os.environ["ORIACALL_CLIENT_SECRET"],
|
|
55
|
+
scope=["hello:read", "objectives:read", "agents:read", "calls:read", "leads:read"],
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
hello = oriacall.hello.get()
|
|
59
|
+
print(hello.data["message"], hello.request_id)
|
|
60
|
+
|
|
61
|
+
calls = oriacall.calls.list({"limit": 50})
|
|
62
|
+
print(calls.data["data"], calls.request_id)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The SDK requests and caches a short-lived access token using client credentials, then sends it as a bearer token for API calls.
|
|
66
|
+
|
|
67
|
+
## Client Options
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
oriacall = Oriacall(
|
|
71
|
+
base_url="https://api.oriacall.com",
|
|
72
|
+
client_id=os.environ["ORIACALL_CLIENT_ID"],
|
|
73
|
+
client_secret=os.environ["ORIACALL_CLIENT_SECRET"],
|
|
74
|
+
scope=["calls:read"],
|
|
75
|
+
retries=2,
|
|
76
|
+
retry_base_delay_ms=250,
|
|
77
|
+
retry_max_delay_ms=2000,
|
|
78
|
+
timeout_seconds=30,
|
|
79
|
+
on_response=lambda event: print(event),
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Options:
|
|
84
|
+
|
|
85
|
+
| Option | Type | Required | Description |
|
|
86
|
+
| --- | --- | --- | --- |
|
|
87
|
+
| `client_id` | `str` | Yes | Developer API client ID. |
|
|
88
|
+
| `client_secret` | `str` | Yes | Developer API client secret. Keep this server-side. |
|
|
89
|
+
| `base_url` | `str` | No | API base URL. Defaults to `https://api.oriacall.com`. |
|
|
90
|
+
| `scope` | `str | list[str] | None` | No | Space-separated string or list of requested token scopes. If omitted, the token request uses all scopes granted to the client. |
|
|
91
|
+
| `session` | `requests.Session | None` | No | Custom session for tests or transport customization. |
|
|
92
|
+
| `on_response` | `callable | None` | No | Called for every SDK-managed HTTP response, including token requests. |
|
|
93
|
+
| `retries` | `int` | No | Retry count for token requests and GET endpoints. Defaults to `0`. |
|
|
94
|
+
| `retry_base_delay_ms` | `int` | No | Initial retry delay. Defaults to `250`. |
|
|
95
|
+
| `retry_max_delay_ms` | `int` | No | Maximum retry delay. Defaults to `2000`. |
|
|
96
|
+
| `timeout_seconds` | `int` | No | HTTP request timeout. Defaults to `30`. |
|
|
97
|
+
|
|
98
|
+
## Response Envelope
|
|
99
|
+
|
|
100
|
+
Every endpoint method returns `ApiResponse`:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
response.data # decoded JSON dict, or None for delete responses
|
|
104
|
+
response.status # HTTP status code
|
|
105
|
+
response.request_id # X-Request-Id when provided
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Methods
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
oriacall.get_access_token()
|
|
112
|
+
oriacall.raw("GET", "/v1/hello")
|
|
113
|
+
oriacall.hello.get()
|
|
114
|
+
|
|
115
|
+
oriacall.objectives.list({"limit": 50})
|
|
116
|
+
oriacall.objectives.update("objective-id", {"customFields": {"region": "north"}})
|
|
117
|
+
oriacall.objectives.paginate({"limit": 50})
|
|
118
|
+
|
|
119
|
+
oriacall.objective_custom_fields.list()
|
|
120
|
+
oriacall.objective_custom_fields.create({"key": "region", "label": "Region", "type": "text"})
|
|
121
|
+
oriacall.objective_custom_fields.update("region", {"label": "Sales Region"})
|
|
122
|
+
|
|
123
|
+
oriacall.agents.list({"objectiveId": "objective-id"})
|
|
124
|
+
oriacall.agents.paginate({"limit": 50})
|
|
125
|
+
|
|
126
|
+
oriacall.calls.list({"limit": 50})
|
|
127
|
+
oriacall.calls.get("call-id")
|
|
128
|
+
oriacall.calls.upload({...})
|
|
129
|
+
oriacall.calls.queue_analysis("call-id")
|
|
130
|
+
oriacall.calls.wait_for_analysis("call-id", {"timeout_ms": 120000})
|
|
131
|
+
oriacall.calls.paginate({"limit": 50})
|
|
132
|
+
|
|
133
|
+
oriacall.leads.list({"customFields": {"crm_stage": "qualified"}})
|
|
134
|
+
oriacall.leads.get("lead-id")
|
|
135
|
+
oriacall.leads.update("lead-id", {"customFields": {"crm_stage": "won"}})
|
|
136
|
+
oriacall.leads.upsert_by_external_id("crm-lead-id", {"firstName": "Ada", "lastName": "Lovelace"})
|
|
137
|
+
oriacall.leads.paginate({"limit": 50})
|
|
138
|
+
|
|
139
|
+
oriacall.lead_custom_fields.list()
|
|
140
|
+
oriacall.lead_custom_fields.create({"key": "crm_stage", "label": "CRM Stage", "type": "text"})
|
|
141
|
+
oriacall.lead_custom_fields.update("crm_stage", {"label": "CRM Stage"})
|
|
142
|
+
|
|
143
|
+
oriacall.webhooks.endpoints.list()
|
|
144
|
+
oriacall.webhooks.endpoints.create({"url": "https://example.com/oriacall/webhooks", "events": ["analysis.completed"]})
|
|
145
|
+
oriacall.webhooks.endpoints.update("endpoint-id", {"isActive": False})
|
|
146
|
+
oriacall.webhooks.endpoints.rotate_secret("endpoint-id")
|
|
147
|
+
oriacall.webhooks.endpoints.test("endpoint-id")
|
|
148
|
+
oriacall.webhooks.endpoints.delete("endpoint-id")
|
|
149
|
+
oriacall.webhooks.endpoints.paginate({"limit": 50})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Upload A Call
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
response = oriacall.calls.upload(
|
|
156
|
+
{
|
|
157
|
+
"idempotencyKey": "crm-call-123",
|
|
158
|
+
"externalId": "crm-call-123",
|
|
159
|
+
"objectiveId": "objective-id",
|
|
160
|
+
"queueAnalysis": True,
|
|
161
|
+
"agent": {
|
|
162
|
+
"externalId": "agent-1",
|
|
163
|
+
"name": "Morgan Agent",
|
|
164
|
+
"email": "morgan@example.com",
|
|
165
|
+
},
|
|
166
|
+
"lead": {
|
|
167
|
+
"externalId": "lead-1",
|
|
168
|
+
"firstName": "Ada",
|
|
169
|
+
"lastName": "Lovelace",
|
|
170
|
+
"phone": "+15555550100",
|
|
171
|
+
"customFields": {"crm_stage": "qualified"},
|
|
172
|
+
},
|
|
173
|
+
"audio": {
|
|
174
|
+
"path": "./call.mp3",
|
|
175
|
+
"filename": "call.mp3",
|
|
176
|
+
"contentType": "audio/mpeg",
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
print(response.data["data"]["id"])
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
To upload in-memory audio, use `contents` instead of `path`:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
"audio": {
|
|
188
|
+
"contents": audio_bytes,
|
|
189
|
+
"filename": "call.mp3",
|
|
190
|
+
"contentType": "audio/mpeg",
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Required scope: `calls:write`.
|
|
195
|
+
|
|
196
|
+
## Pagination
|
|
197
|
+
|
|
198
|
+
List endpoints use cursor pagination.
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
first_page = oriacall.calls.list({"limit": 50})
|
|
202
|
+
|
|
203
|
+
if cursor := first_page.data["pagination"]["nextCursor"]:
|
|
204
|
+
second_page = oriacall.calls.list({"limit": 50, "cursor": cursor})
|
|
205
|
+
|
|
206
|
+
for call in oriacall.calls.paginate({"limit": 50}):
|
|
207
|
+
print(call["id"])
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Pagination helpers are available for `objectives`, `agents`, `calls`, `leads`, and `webhooks.endpoints`.
|
|
211
|
+
|
|
212
|
+
## Custom Field Filters
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
oriacall.objectives.list(
|
|
216
|
+
{
|
|
217
|
+
"objectiveCustomFields": {
|
|
218
|
+
"region": "north",
|
|
219
|
+
"priority": {"gte": 5},
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
oriacall.calls.list(
|
|
225
|
+
{
|
|
226
|
+
"leadCustomFields": {
|
|
227
|
+
"crm_stage": "qualified",
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
oriacall.leads.list(
|
|
233
|
+
{
|
|
234
|
+
"customFields": {
|
|
235
|
+
"crm_stage": "qualified",
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Snake-case aliases are also accepted for SDK option names such as `lead_custom_fields`, `custom_fields`, and `objective_custom_fields`.
|
|
242
|
+
|
|
243
|
+
## Errors
|
|
244
|
+
|
|
245
|
+
Failed API calls raise `OriacallApiError`:
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
from oriacall import OriacallApiError
|
|
249
|
+
|
|
250
|
+
try:
|
|
251
|
+
oriacall.calls.get("call-id")
|
|
252
|
+
except OriacallApiError as error:
|
|
253
|
+
print(error.status)
|
|
254
|
+
print(error.code)
|
|
255
|
+
print(error.message)
|
|
256
|
+
print(error.request_id)
|
|
257
|
+
print(error.details)
|
|
258
|
+
print(error.retry_after)
|
|
259
|
+
print(error.is_rate_limited)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Webhook Signature Verification
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from oriacall import verify_webhook_signature
|
|
266
|
+
|
|
267
|
+
valid = verify_webhook_signature(
|
|
268
|
+
body=request_body,
|
|
269
|
+
secret=webhook_secret,
|
|
270
|
+
signature=headers["Oriacall-Signature"],
|
|
271
|
+
timestamp=headers["Oriacall-Timestamp"],
|
|
272
|
+
)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Scopes
|
|
276
|
+
|
|
277
|
+
Available scopes:
|
|
278
|
+
|
|
279
|
+
```text
|
|
280
|
+
hello:read
|
|
281
|
+
objectives:read
|
|
282
|
+
objectives:write
|
|
283
|
+
objective_custom_fields:manage
|
|
284
|
+
agents:read
|
|
285
|
+
calls:read
|
|
286
|
+
calls:write
|
|
287
|
+
leads:read
|
|
288
|
+
leads:write
|
|
289
|
+
lead_custom_fields:manage
|
|
290
|
+
webhooks:read
|
|
291
|
+
webhooks:write
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
The token request can only request scopes that were granted to that API client.
|
oriacall-0.1.0/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# oriacall
|
|
2
|
+
|
|
3
|
+
Python SDK for the Oriacall Developer API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install oriacall
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requirements:
|
|
12
|
+
|
|
13
|
+
- Python 3.9 or newer.
|
|
14
|
+
- An Oriacall Developer API client ID and secret.
|
|
15
|
+
- Server-side usage only. Do not expose `client_secret` in browser or client app code.
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
from oriacall import Oriacall
|
|
23
|
+
|
|
24
|
+
oriacall = Oriacall(
|
|
25
|
+
client_id=os.environ["ORIACALL_CLIENT_ID"],
|
|
26
|
+
client_secret=os.environ["ORIACALL_CLIENT_SECRET"],
|
|
27
|
+
scope=["hello:read", "objectives:read", "agents:read", "calls:read", "leads:read"],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
hello = oriacall.hello.get()
|
|
31
|
+
print(hello.data["message"], hello.request_id)
|
|
32
|
+
|
|
33
|
+
calls = oriacall.calls.list({"limit": 50})
|
|
34
|
+
print(calls.data["data"], calls.request_id)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The SDK requests and caches a short-lived access token using client credentials, then sends it as a bearer token for API calls.
|
|
38
|
+
|
|
39
|
+
## Client Options
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
oriacall = Oriacall(
|
|
43
|
+
base_url="https://api.oriacall.com",
|
|
44
|
+
client_id=os.environ["ORIACALL_CLIENT_ID"],
|
|
45
|
+
client_secret=os.environ["ORIACALL_CLIENT_SECRET"],
|
|
46
|
+
scope=["calls:read"],
|
|
47
|
+
retries=2,
|
|
48
|
+
retry_base_delay_ms=250,
|
|
49
|
+
retry_max_delay_ms=2000,
|
|
50
|
+
timeout_seconds=30,
|
|
51
|
+
on_response=lambda event: print(event),
|
|
52
|
+
)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Options:
|
|
56
|
+
|
|
57
|
+
| Option | Type | Required | Description |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
| `client_id` | `str` | Yes | Developer API client ID. |
|
|
60
|
+
| `client_secret` | `str` | Yes | Developer API client secret. Keep this server-side. |
|
|
61
|
+
| `base_url` | `str` | No | API base URL. Defaults to `https://api.oriacall.com`. |
|
|
62
|
+
| `scope` | `str | list[str] | None` | No | Space-separated string or list of requested token scopes. If omitted, the token request uses all scopes granted to the client. |
|
|
63
|
+
| `session` | `requests.Session | None` | No | Custom session for tests or transport customization. |
|
|
64
|
+
| `on_response` | `callable | None` | No | Called for every SDK-managed HTTP response, including token requests. |
|
|
65
|
+
| `retries` | `int` | No | Retry count for token requests and GET endpoints. Defaults to `0`. |
|
|
66
|
+
| `retry_base_delay_ms` | `int` | No | Initial retry delay. Defaults to `250`. |
|
|
67
|
+
| `retry_max_delay_ms` | `int` | No | Maximum retry delay. Defaults to `2000`. |
|
|
68
|
+
| `timeout_seconds` | `int` | No | HTTP request timeout. Defaults to `30`. |
|
|
69
|
+
|
|
70
|
+
## Response Envelope
|
|
71
|
+
|
|
72
|
+
Every endpoint method returns `ApiResponse`:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
response.data # decoded JSON dict, or None for delete responses
|
|
76
|
+
response.status # HTTP status code
|
|
77
|
+
response.request_id # X-Request-Id when provided
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Methods
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
oriacall.get_access_token()
|
|
84
|
+
oriacall.raw("GET", "/v1/hello")
|
|
85
|
+
oriacall.hello.get()
|
|
86
|
+
|
|
87
|
+
oriacall.objectives.list({"limit": 50})
|
|
88
|
+
oriacall.objectives.update("objective-id", {"customFields": {"region": "north"}})
|
|
89
|
+
oriacall.objectives.paginate({"limit": 50})
|
|
90
|
+
|
|
91
|
+
oriacall.objective_custom_fields.list()
|
|
92
|
+
oriacall.objective_custom_fields.create({"key": "region", "label": "Region", "type": "text"})
|
|
93
|
+
oriacall.objective_custom_fields.update("region", {"label": "Sales Region"})
|
|
94
|
+
|
|
95
|
+
oriacall.agents.list({"objectiveId": "objective-id"})
|
|
96
|
+
oriacall.agents.paginate({"limit": 50})
|
|
97
|
+
|
|
98
|
+
oriacall.calls.list({"limit": 50})
|
|
99
|
+
oriacall.calls.get("call-id")
|
|
100
|
+
oriacall.calls.upload({...})
|
|
101
|
+
oriacall.calls.queue_analysis("call-id")
|
|
102
|
+
oriacall.calls.wait_for_analysis("call-id", {"timeout_ms": 120000})
|
|
103
|
+
oriacall.calls.paginate({"limit": 50})
|
|
104
|
+
|
|
105
|
+
oriacall.leads.list({"customFields": {"crm_stage": "qualified"}})
|
|
106
|
+
oriacall.leads.get("lead-id")
|
|
107
|
+
oriacall.leads.update("lead-id", {"customFields": {"crm_stage": "won"}})
|
|
108
|
+
oriacall.leads.upsert_by_external_id("crm-lead-id", {"firstName": "Ada", "lastName": "Lovelace"})
|
|
109
|
+
oriacall.leads.paginate({"limit": 50})
|
|
110
|
+
|
|
111
|
+
oriacall.lead_custom_fields.list()
|
|
112
|
+
oriacall.lead_custom_fields.create({"key": "crm_stage", "label": "CRM Stage", "type": "text"})
|
|
113
|
+
oriacall.lead_custom_fields.update("crm_stage", {"label": "CRM Stage"})
|
|
114
|
+
|
|
115
|
+
oriacall.webhooks.endpoints.list()
|
|
116
|
+
oriacall.webhooks.endpoints.create({"url": "https://example.com/oriacall/webhooks", "events": ["analysis.completed"]})
|
|
117
|
+
oriacall.webhooks.endpoints.update("endpoint-id", {"isActive": False})
|
|
118
|
+
oriacall.webhooks.endpoints.rotate_secret("endpoint-id")
|
|
119
|
+
oriacall.webhooks.endpoints.test("endpoint-id")
|
|
120
|
+
oriacall.webhooks.endpoints.delete("endpoint-id")
|
|
121
|
+
oriacall.webhooks.endpoints.paginate({"limit": 50})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Upload A Call
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
response = oriacall.calls.upload(
|
|
128
|
+
{
|
|
129
|
+
"idempotencyKey": "crm-call-123",
|
|
130
|
+
"externalId": "crm-call-123",
|
|
131
|
+
"objectiveId": "objective-id",
|
|
132
|
+
"queueAnalysis": True,
|
|
133
|
+
"agent": {
|
|
134
|
+
"externalId": "agent-1",
|
|
135
|
+
"name": "Morgan Agent",
|
|
136
|
+
"email": "morgan@example.com",
|
|
137
|
+
},
|
|
138
|
+
"lead": {
|
|
139
|
+
"externalId": "lead-1",
|
|
140
|
+
"firstName": "Ada",
|
|
141
|
+
"lastName": "Lovelace",
|
|
142
|
+
"phone": "+15555550100",
|
|
143
|
+
"customFields": {"crm_stage": "qualified"},
|
|
144
|
+
},
|
|
145
|
+
"audio": {
|
|
146
|
+
"path": "./call.mp3",
|
|
147
|
+
"filename": "call.mp3",
|
|
148
|
+
"contentType": "audio/mpeg",
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
print(response.data["data"]["id"])
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
To upload in-memory audio, use `contents` instead of `path`:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
"audio": {
|
|
160
|
+
"contents": audio_bytes,
|
|
161
|
+
"filename": "call.mp3",
|
|
162
|
+
"contentType": "audio/mpeg",
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Required scope: `calls:write`.
|
|
167
|
+
|
|
168
|
+
## Pagination
|
|
169
|
+
|
|
170
|
+
List endpoints use cursor pagination.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
first_page = oriacall.calls.list({"limit": 50})
|
|
174
|
+
|
|
175
|
+
if cursor := first_page.data["pagination"]["nextCursor"]:
|
|
176
|
+
second_page = oriacall.calls.list({"limit": 50, "cursor": cursor})
|
|
177
|
+
|
|
178
|
+
for call in oriacall.calls.paginate({"limit": 50}):
|
|
179
|
+
print(call["id"])
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Pagination helpers are available for `objectives`, `agents`, `calls`, `leads`, and `webhooks.endpoints`.
|
|
183
|
+
|
|
184
|
+
## Custom Field Filters
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
oriacall.objectives.list(
|
|
188
|
+
{
|
|
189
|
+
"objectiveCustomFields": {
|
|
190
|
+
"region": "north",
|
|
191
|
+
"priority": {"gte": 5},
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
oriacall.calls.list(
|
|
197
|
+
{
|
|
198
|
+
"leadCustomFields": {
|
|
199
|
+
"crm_stage": "qualified",
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
oriacall.leads.list(
|
|
205
|
+
{
|
|
206
|
+
"customFields": {
|
|
207
|
+
"crm_stage": "qualified",
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Snake-case aliases are also accepted for SDK option names such as `lead_custom_fields`, `custom_fields`, and `objective_custom_fields`.
|
|
214
|
+
|
|
215
|
+
## Errors
|
|
216
|
+
|
|
217
|
+
Failed API calls raise `OriacallApiError`:
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from oriacall import OriacallApiError
|
|
221
|
+
|
|
222
|
+
try:
|
|
223
|
+
oriacall.calls.get("call-id")
|
|
224
|
+
except OriacallApiError as error:
|
|
225
|
+
print(error.status)
|
|
226
|
+
print(error.code)
|
|
227
|
+
print(error.message)
|
|
228
|
+
print(error.request_id)
|
|
229
|
+
print(error.details)
|
|
230
|
+
print(error.retry_after)
|
|
231
|
+
print(error.is_rate_limited)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Webhook Signature Verification
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
from oriacall import verify_webhook_signature
|
|
238
|
+
|
|
239
|
+
valid = verify_webhook_signature(
|
|
240
|
+
body=request_body,
|
|
241
|
+
secret=webhook_secret,
|
|
242
|
+
signature=headers["Oriacall-Signature"],
|
|
243
|
+
timestamp=headers["Oriacall-Timestamp"],
|
|
244
|
+
)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Scopes
|
|
248
|
+
|
|
249
|
+
Available scopes:
|
|
250
|
+
|
|
251
|
+
```text
|
|
252
|
+
hello:read
|
|
253
|
+
objectives:read
|
|
254
|
+
objectives:write
|
|
255
|
+
objective_custom_fields:manage
|
|
256
|
+
agents:read
|
|
257
|
+
calls:read
|
|
258
|
+
calls:write
|
|
259
|
+
leads:read
|
|
260
|
+
leads:write
|
|
261
|
+
lead_custom_fields:manage
|
|
262
|
+
webhooks:read
|
|
263
|
+
webhooks:write
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
The token request can only request scopes that were granted to that API client.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "oriacall"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for the Oriacall Developer API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Oriacall" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["oriacall", "sdk", "api", "python"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"requests>=2.31.0"
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/Karim-Chrif/oriacall-python-sdk#readme"
|
|
33
|
+
Repository = "https://github.com/Karim-Chrif/oriacall-python-sdk"
|
|
34
|
+
Issues = "https://github.com/Karim-Chrif/oriacall-python-sdk/issues"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"build>=1.2.0",
|
|
39
|
+
"pytest>=8.0.0",
|
|
40
|
+
"ruff>=0.8.0"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/oriacall"]
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
line-length = 100
|
|
48
|
+
target-version = "py39"
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .client import Oriacall, create_client, verify_webhook_signature
|
|
2
|
+
from .errors import OriacallApiError
|
|
3
|
+
from .response import ApiResponse
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"ApiResponse",
|
|
7
|
+
"Oriacall",
|
|
8
|
+
"OriacallApiError",
|
|
9
|
+
"create_client",
|
|
10
|
+
"verify_webhook_signature",
|
|
11
|
+
]
|