syllable-sdk 0.35.32__py3-none-any.whl → 0.35.33__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.
Files changed (51) hide show
  1. syllable_sdk/__init__.py +0 -1
  2. syllable_sdk/_version.py +3 -3
  3. syllable_sdk/agents.py +83 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +131 -329
  6. syllable_sdk/campaigns.py +73 -183
  7. syllable_sdk/channels.py +29 -73
  8. syllable_sdk/conversations.py +19 -37
  9. syllable_sdk/custom_messages.py +73 -183
  10. syllable_sdk/dashboards.py +67 -195
  11. syllable_sdk/data_sources.py +85 -183
  12. syllable_sdk/errors/__init__.py +55 -0
  13. syllable_sdk/errors/apierror.py +38 -0
  14. syllable_sdk/errors/httpvalidationerror.py +26 -0
  15. syllable_sdk/errors/no_response_error.py +13 -0
  16. syllable_sdk/errors/responsevalidationerror.py +25 -0
  17. syllable_sdk/errors/syllablesdkerror.py +26 -0
  18. syllable_sdk/events.py +15 -37
  19. syllable_sdk/folders.py +121 -293
  20. syllable_sdk/full_summary.py +19 -37
  21. syllable_sdk/incidents.py +83 -215
  22. syllable_sdk/insights_sdk.py +17 -39
  23. syllable_sdk/insights_tools.py +97 -251
  24. syllable_sdk/language_groups.py +85 -215
  25. syllable_sdk/latency.py +19 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +53 -111
  28. syllable_sdk/organizations.py +51 -139
  29. syllable_sdk/permissions.py +11 -33
  30. syllable_sdk/prompts.py +95 -249
  31. syllable_sdk/roles.py +75 -181
  32. syllable_sdk/services.py +73 -183
  33. syllable_sdk/session_debug.py +43 -109
  34. syllable_sdk/session_labels.py +47 -109
  35. syllable_sdk/sessions.py +59 -141
  36. syllable_sdk/takeouts.py +35 -99
  37. syllable_sdk/targets.py +75 -185
  38. syllable_sdk/test.py +15 -37
  39. syllable_sdk/tools.py +75 -181
  40. syllable_sdk/transcript.py +17 -39
  41. syllable_sdk/twilio.py +43 -109
  42. syllable_sdk/users.py +97 -247
  43. syllable_sdk/utils/__init__.py +3 -0
  44. syllable_sdk/utils/serializers.py +21 -3
  45. syllable_sdk/v1.py +97 -247
  46. syllable_sdk/workflows.py +115 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
  49. syllable_sdk/models/apierror.py +0 -22
  50. syllable_sdk/models/httpvalidationerror.py +0 -21
  51. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from syllable_sdk import models, utils
4
+ from syllable_sdk import errors, models, utils
5
5
  from syllable_sdk._hooks import HookContext
6
6
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -83,31 +83,20 @@ class SessionLabels(BaseSDK):
83
83
 
84
84
  response_data: Any = None
85
85
  if utils.match_response(http_res, "200", "application/json"):
86
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
86
+ return utils.unmarshal_json_response(models.SessionLabel, http_res)
87
87
  if utils.match_response(http_res, "422", "application/json"):
88
- response_data = utils.unmarshal_json(
89
- http_res.text, models.HTTPValidationErrorData
88
+ response_data = utils.unmarshal_json_response(
89
+ errors.HTTPValidationErrorData, http_res
90
90
  )
91
- raise models.HTTPValidationError(data=response_data)
91
+ raise errors.HTTPValidationError(response_data, http_res)
92
92
  if utils.match_response(http_res, "4XX", "*"):
93
93
  http_res_text = utils.stream_to_text(http_res)
94
- raise models.APIError(
95
- "API error occurred", http_res.status_code, http_res_text, http_res
96
- )
94
+ raise errors.APIError("API error occurred", http_res, http_res_text)
97
95
  if utils.match_response(http_res, "5XX", "*"):
98
96
  http_res_text = utils.stream_to_text(http_res)
99
- raise models.APIError(
100
- "API error occurred", http_res.status_code, http_res_text, http_res
101
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
98
 
103
- content_type = http_res.headers.get("Content-Type")
104
- http_res_text = utils.stream_to_text(http_res)
105
- raise models.APIError(
106
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
107
- http_res.status_code,
108
- http_res_text,
109
- http_res,
110
- )
99
+ raise errors.APIError("Unexpected response received", http_res)
111
100
 
112
101
  async def get_by_id_async(
113
102
  self,
@@ -181,31 +170,20 @@ class SessionLabels(BaseSDK):
181
170
 
182
171
  response_data: Any = None
183
172
  if utils.match_response(http_res, "200", "application/json"):
184
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
173
+ return utils.unmarshal_json_response(models.SessionLabel, http_res)
185
174
  if utils.match_response(http_res, "422", "application/json"):
186
- response_data = utils.unmarshal_json(
187
- http_res.text, models.HTTPValidationErrorData
175
+ response_data = utils.unmarshal_json_response(
176
+ errors.HTTPValidationErrorData, http_res
188
177
  )
189
- raise models.HTTPValidationError(data=response_data)
178
+ raise errors.HTTPValidationError(response_data, http_res)
190
179
  if utils.match_response(http_res, "4XX", "*"):
191
180
  http_res_text = await utils.stream_to_text_async(http_res)
192
- raise models.APIError(
193
- "API error occurred", http_res.status_code, http_res_text, http_res
194
- )
181
+ raise errors.APIError("API error occurred", http_res, http_res_text)
195
182
  if utils.match_response(http_res, "5XX", "*"):
196
183
  http_res_text = await utils.stream_to_text_async(http_res)
197
- raise models.APIError(
198
- "API error occurred", http_res.status_code, http_res_text, http_res
199
- )
184
+ raise errors.APIError("API error occurred", http_res, http_res_text)
200
185
 
201
- content_type = http_res.headers.get("Content-Type")
202
- http_res_text = await utils.stream_to_text_async(http_res)
203
- raise models.APIError(
204
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
205
- http_res.status_code,
206
- http_res_text,
207
- http_res,
208
- )
186
+ raise errors.APIError("Unexpected response received", http_res)
209
187
 
210
188
  def create(
211
189
  self,
@@ -284,31 +262,20 @@ class SessionLabels(BaseSDK):
284
262
 
285
263
  response_data: Any = None
286
264
  if utils.match_response(http_res, "200", "application/json"):
287
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
265
+ return utils.unmarshal_json_response(models.SessionLabel, http_res)
288
266
  if utils.match_response(http_res, "422", "application/json"):
289
- response_data = utils.unmarshal_json(
290
- http_res.text, models.HTTPValidationErrorData
267
+ response_data = utils.unmarshal_json_response(
268
+ errors.HTTPValidationErrorData, http_res
291
269
  )
292
- raise models.HTTPValidationError(data=response_data)
270
+ raise errors.HTTPValidationError(response_data, http_res)
293
271
  if utils.match_response(http_res, "4XX", "*"):
294
272
  http_res_text = utils.stream_to_text(http_res)
295
- raise models.APIError(
296
- "API error occurred", http_res.status_code, http_res_text, http_res
297
- )
273
+ raise errors.APIError("API error occurred", http_res, http_res_text)
298
274
  if utils.match_response(http_res, "5XX", "*"):
299
275
  http_res_text = utils.stream_to_text(http_res)
300
- raise models.APIError(
301
- "API error occurred", http_res.status_code, http_res_text, http_res
302
- )
276
+ raise errors.APIError("API error occurred", http_res, http_res_text)
303
277
 
304
- content_type = http_res.headers.get("Content-Type")
305
- http_res_text = utils.stream_to_text(http_res)
306
- raise models.APIError(
307
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
308
- http_res.status_code,
309
- http_res_text,
310
- http_res,
311
- )
278
+ raise errors.APIError("Unexpected response received", http_res)
312
279
 
313
280
  async def create_async(
314
281
  self,
@@ -387,31 +354,20 @@ class SessionLabels(BaseSDK):
387
354
 
388
355
  response_data: Any = None
389
356
  if utils.match_response(http_res, "200", "application/json"):
390
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
357
+ return utils.unmarshal_json_response(models.SessionLabel, http_res)
391
358
  if utils.match_response(http_res, "422", "application/json"):
392
- response_data = utils.unmarshal_json(
393
- http_res.text, models.HTTPValidationErrorData
359
+ response_data = utils.unmarshal_json_response(
360
+ errors.HTTPValidationErrorData, http_res
394
361
  )
395
- raise models.HTTPValidationError(data=response_data)
362
+ raise errors.HTTPValidationError(response_data, http_res)
396
363
  if utils.match_response(http_res, "4XX", "*"):
397
364
  http_res_text = await utils.stream_to_text_async(http_res)
398
- raise models.APIError(
399
- "API error occurred", http_res.status_code, http_res_text, http_res
400
- )
365
+ raise errors.APIError("API error occurred", http_res, http_res_text)
401
366
  if utils.match_response(http_res, "5XX", "*"):
402
367
  http_res_text = await utils.stream_to_text_async(http_res)
403
- raise models.APIError(
404
- "API error occurred", http_res.status_code, http_res_text, http_res
405
- )
368
+ raise errors.APIError("API error occurred", http_res, http_res_text)
406
369
 
407
- content_type = http_res.headers.get("Content-Type")
408
- http_res_text = await utils.stream_to_text_async(http_res)
409
- raise models.APIError(
410
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
411
- http_res.status_code,
412
- http_res_text,
413
- http_res,
414
- )
370
+ raise errors.APIError("Unexpected response received", http_res)
415
371
 
416
372
  def list(
417
373
  self,
@@ -509,31 +465,22 @@ class SessionLabels(BaseSDK):
509
465
 
510
466
  response_data: Any = None
511
467
  if utils.match_response(http_res, "200", "application/json"):
512
- return utils.unmarshal_json(http_res.text, models.ListResponseSessionLabel)
468
+ return utils.unmarshal_json_response(
469
+ models.ListResponseSessionLabel, http_res
470
+ )
513
471
  if utils.match_response(http_res, "422", "application/json"):
514
- response_data = utils.unmarshal_json(
515
- http_res.text, models.HTTPValidationErrorData
472
+ response_data = utils.unmarshal_json_response(
473
+ errors.HTTPValidationErrorData, http_res
516
474
  )
517
- raise models.HTTPValidationError(data=response_data)
475
+ raise errors.HTTPValidationError(response_data, http_res)
518
476
  if utils.match_response(http_res, "4XX", "*"):
519
477
  http_res_text = utils.stream_to_text(http_res)
520
- raise models.APIError(
521
- "API error occurred", http_res.status_code, http_res_text, http_res
522
- )
478
+ raise errors.APIError("API error occurred", http_res, http_res_text)
523
479
  if utils.match_response(http_res, "5XX", "*"):
524
480
  http_res_text = utils.stream_to_text(http_res)
525
- raise models.APIError(
526
- "API error occurred", http_res.status_code, http_res_text, http_res
527
- )
481
+ raise errors.APIError("API error occurred", http_res, http_res_text)
528
482
 
529
- content_type = http_res.headers.get("Content-Type")
530
- http_res_text = utils.stream_to_text(http_res)
531
- raise models.APIError(
532
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
533
- http_res.status_code,
534
- http_res_text,
535
- http_res,
536
- )
483
+ raise errors.APIError("Unexpected response received", http_res)
537
484
 
538
485
  async def list_async(
539
486
  self,
@@ -631,28 +578,19 @@ class SessionLabels(BaseSDK):
631
578
 
632
579
  response_data: Any = None
633
580
  if utils.match_response(http_res, "200", "application/json"):
634
- return utils.unmarshal_json(http_res.text, models.ListResponseSessionLabel)
581
+ return utils.unmarshal_json_response(
582
+ models.ListResponseSessionLabel, http_res
583
+ )
635
584
  if utils.match_response(http_res, "422", "application/json"):
636
- response_data = utils.unmarshal_json(
637
- http_res.text, models.HTTPValidationErrorData
585
+ response_data = utils.unmarshal_json_response(
586
+ errors.HTTPValidationErrorData, http_res
638
587
  )
639
- raise models.HTTPValidationError(data=response_data)
588
+ raise errors.HTTPValidationError(response_data, http_res)
640
589
  if utils.match_response(http_res, "4XX", "*"):
641
590
  http_res_text = await utils.stream_to_text_async(http_res)
642
- raise models.APIError(
643
- "API error occurred", http_res.status_code, http_res_text, http_res
644
- )
591
+ raise errors.APIError("API error occurred", http_res, http_res_text)
645
592
  if utils.match_response(http_res, "5XX", "*"):
646
593
  http_res_text = await utils.stream_to_text_async(http_res)
647
- raise models.APIError(
648
- "API error occurred", http_res.status_code, http_res_text, http_res
649
- )
594
+ raise errors.APIError("API error occurred", http_res, http_res_text)
650
595
 
651
- content_type = http_res.headers.get("Content-Type")
652
- http_res_text = await utils.stream_to_text_async(http_res)
653
- raise models.APIError(
654
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
655
- http_res.status_code,
656
- http_res_text,
657
- http_res,
658
- )
596
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/sessions.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from .basesdk import BaseSDK
4
4
  from .sdkconfiguration import SDKConfiguration
5
5
  import httpx
6
- from syllable_sdk import models, utils
6
+ from syllable_sdk import errors, models, utils
7
7
  from syllable_sdk._hooks import HookContext
8
8
  from syllable_sdk.full_summary import FullSummary
9
9
  from syllable_sdk.latency import Latency
@@ -126,31 +126,20 @@ class Sessions(BaseSDK):
126
126
 
127
127
  response_data: Any = None
128
128
  if utils.match_response(http_res, "200", "application/json"):
129
- return utils.unmarshal_json(http_res.text, models.ListResponseSession)
129
+ return utils.unmarshal_json_response(models.ListResponseSession, http_res)
130
130
  if utils.match_response(http_res, "422", "application/json"):
131
- response_data = utils.unmarshal_json(
132
- http_res.text, models.HTTPValidationErrorData
131
+ response_data = utils.unmarshal_json_response(
132
+ errors.HTTPValidationErrorData, http_res
133
133
  )
134
- raise models.HTTPValidationError(data=response_data)
134
+ raise errors.HTTPValidationError(response_data, http_res)
135
135
  if utils.match_response(http_res, "4XX", "*"):
136
136
  http_res_text = utils.stream_to_text(http_res)
137
- raise models.APIError(
138
- "API error occurred", http_res.status_code, http_res_text, http_res
139
- )
137
+ raise errors.APIError("API error occurred", http_res, http_res_text)
140
138
  if utils.match_response(http_res, "5XX", "*"):
141
139
  http_res_text = utils.stream_to_text(http_res)
142
- raise models.APIError(
143
- "API error occurred", http_res.status_code, http_res_text, http_res
144
- )
140
+ raise errors.APIError("API error occurred", http_res, http_res_text)
145
141
 
146
- content_type = http_res.headers.get("Content-Type")
147
- http_res_text = utils.stream_to_text(http_res)
148
- raise models.APIError(
149
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
150
- http_res.status_code,
151
- http_res_text,
152
- http_res,
153
- )
142
+ raise errors.APIError("Unexpected response received", http_res)
154
143
 
155
144
  async def list_async(
156
145
  self,
@@ -248,31 +237,20 @@ class Sessions(BaseSDK):
248
237
 
249
238
  response_data: Any = None
250
239
  if utils.match_response(http_res, "200", "application/json"):
251
- return utils.unmarshal_json(http_res.text, models.ListResponseSession)
240
+ return utils.unmarshal_json_response(models.ListResponseSession, http_res)
252
241
  if utils.match_response(http_res, "422", "application/json"):
253
- response_data = utils.unmarshal_json(
254
- http_res.text, models.HTTPValidationErrorData
242
+ response_data = utils.unmarshal_json_response(
243
+ errors.HTTPValidationErrorData, http_res
255
244
  )
256
- raise models.HTTPValidationError(data=response_data)
245
+ raise errors.HTTPValidationError(response_data, http_res)
257
246
  if utils.match_response(http_res, "4XX", "*"):
258
247
  http_res_text = await utils.stream_to_text_async(http_res)
259
- raise models.APIError(
260
- "API error occurred", http_res.status_code, http_res_text, http_res
261
- )
248
+ raise errors.APIError("API error occurred", http_res, http_res_text)
262
249
  if utils.match_response(http_res, "5XX", "*"):
263
250
  http_res_text = await utils.stream_to_text_async(http_res)
264
- raise models.APIError(
265
- "API error occurred", http_res.status_code, http_res_text, http_res
266
- )
251
+ raise errors.APIError("API error occurred", http_res, http_res_text)
267
252
 
268
- content_type = http_res.headers.get("Content-Type")
269
- http_res_text = await utils.stream_to_text_async(http_res)
270
- raise models.APIError(
271
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
272
- http_res.status_code,
273
- http_res_text,
274
- http_res,
275
- )
253
+ raise errors.APIError("Unexpected response received", http_res)
276
254
 
277
255
  def get_by_id(
278
256
  self,
@@ -346,31 +324,20 @@ class Sessions(BaseSDK):
346
324
 
347
325
  response_data: Any = None
348
326
  if utils.match_response(http_res, "200", "application/json"):
349
- return utils.unmarshal_json(http_res.text, models.Session)
327
+ return utils.unmarshal_json_response(models.Session, http_res)
350
328
  if utils.match_response(http_res, "422", "application/json"):
351
- response_data = utils.unmarshal_json(
352
- http_res.text, models.HTTPValidationErrorData
329
+ response_data = utils.unmarshal_json_response(
330
+ errors.HTTPValidationErrorData, http_res
353
331
  )
354
- raise models.HTTPValidationError(data=response_data)
332
+ raise errors.HTTPValidationError(response_data, http_res)
355
333
  if utils.match_response(http_res, "4XX", "*"):
356
334
  http_res_text = utils.stream_to_text(http_res)
357
- raise models.APIError(
358
- "API error occurred", http_res.status_code, http_res_text, http_res
359
- )
335
+ raise errors.APIError("API error occurred", http_res, http_res_text)
360
336
  if utils.match_response(http_res, "5XX", "*"):
361
337
  http_res_text = utils.stream_to_text(http_res)
362
- raise models.APIError(
363
- "API error occurred", http_res.status_code, http_res_text, http_res
364
- )
338
+ raise errors.APIError("API error occurred", http_res, http_res_text)
365
339
 
366
- content_type = http_res.headers.get("Content-Type")
367
- http_res_text = utils.stream_to_text(http_res)
368
- raise models.APIError(
369
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
370
- http_res.status_code,
371
- http_res_text,
372
- http_res,
373
- )
340
+ raise errors.APIError("Unexpected response received", http_res)
374
341
 
375
342
  async def get_by_id_async(
376
343
  self,
@@ -444,31 +411,20 @@ class Sessions(BaseSDK):
444
411
 
445
412
  response_data: Any = None
446
413
  if utils.match_response(http_res, "200", "application/json"):
447
- return utils.unmarshal_json(http_res.text, models.Session)
414
+ return utils.unmarshal_json_response(models.Session, http_res)
448
415
  if utils.match_response(http_res, "422", "application/json"):
449
- response_data = utils.unmarshal_json(
450
- http_res.text, models.HTTPValidationErrorData
416
+ response_data = utils.unmarshal_json_response(
417
+ errors.HTTPValidationErrorData, http_res
451
418
  )
452
- raise models.HTTPValidationError(data=response_data)
419
+ raise errors.HTTPValidationError(response_data, http_res)
453
420
  if utils.match_response(http_res, "4XX", "*"):
454
421
  http_res_text = await utils.stream_to_text_async(http_res)
455
- raise models.APIError(
456
- "API error occurred", http_res.status_code, http_res_text, http_res
457
- )
422
+ raise errors.APIError("API error occurred", http_res, http_res_text)
458
423
  if utils.match_response(http_res, "5XX", "*"):
459
424
  http_res_text = await utils.stream_to_text_async(http_res)
460
- raise models.APIError(
461
- "API error occurred", http_res.status_code, http_res_text, http_res
462
- )
425
+ raise errors.APIError("API error occurred", http_res, http_res_text)
463
426
 
464
- content_type = http_res.headers.get("Content-Type")
465
- http_res_text = await utils.stream_to_text_async(http_res)
466
- raise models.APIError(
467
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
468
- http_res.status_code,
469
- http_res_text,
470
- http_res,
471
- )
427
+ raise errors.APIError("Unexpected response received", http_res)
472
428
 
473
429
  def generate_session_recording_urls(
474
430
  self,
@@ -542,31 +498,22 @@ class Sessions(BaseSDK):
542
498
 
543
499
  response_data: Any = None
544
500
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.SessionRecordingResponse)
501
+ return utils.unmarshal_json_response(
502
+ models.SessionRecordingResponse, http_res
503
+ )
546
504
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
505
+ response_data = utils.unmarshal_json_response(
506
+ errors.HTTPValidationErrorData, http_res
549
507
  )
550
- raise models.HTTPValidationError(data=response_data)
508
+ raise errors.HTTPValidationError(response_data, http_res)
551
509
  if utils.match_response(http_res, "4XX", "*"):
552
510
  http_res_text = utils.stream_to_text(http_res)
553
- raise models.APIError(
554
- "API error occurred", http_res.status_code, http_res_text, http_res
555
- )
511
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
512
  if utils.match_response(http_res, "5XX", "*"):
557
513
  http_res_text = utils.stream_to_text(http_res)
558
- raise models.APIError(
559
- "API error occurred", http_res.status_code, http_res_text, http_res
560
- )
514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
515
 
562
- content_type = http_res.headers.get("Content-Type")
563
- http_res_text = utils.stream_to_text(http_res)
564
- raise models.APIError(
565
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
566
- http_res.status_code,
567
- http_res_text,
568
- http_res,
569
- )
516
+ raise errors.APIError("Unexpected response received", http_res)
570
517
 
571
518
  async def generate_session_recording_urls_async(
572
519
  self,
@@ -640,31 +587,22 @@ class Sessions(BaseSDK):
640
587
 
641
588
  response_data: Any = None
642
589
  if utils.match_response(http_res, "200", "application/json"):
643
- return utils.unmarshal_json(http_res.text, models.SessionRecordingResponse)
590
+ return utils.unmarshal_json_response(
591
+ models.SessionRecordingResponse, http_res
592
+ )
644
593
  if utils.match_response(http_res, "422", "application/json"):
645
- response_data = utils.unmarshal_json(
646
- http_res.text, models.HTTPValidationErrorData
594
+ response_data = utils.unmarshal_json_response(
595
+ errors.HTTPValidationErrorData, http_res
647
596
  )
648
- raise models.HTTPValidationError(data=response_data)
597
+ raise errors.HTTPValidationError(response_data, http_res)
649
598
  if utils.match_response(http_res, "4XX", "*"):
650
599
  http_res_text = await utils.stream_to_text_async(http_res)
651
- raise models.APIError(
652
- "API error occurred", http_res.status_code, http_res_text, http_res
653
- )
600
+ raise errors.APIError("API error occurred", http_res, http_res_text)
654
601
  if utils.match_response(http_res, "5XX", "*"):
655
602
  http_res_text = await utils.stream_to_text_async(http_res)
656
- raise models.APIError(
657
- "API error occurred", http_res.status_code, http_res_text, http_res
658
- )
603
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
604
 
660
- content_type = http_res.headers.get("Content-Type")
661
- http_res_text = await utils.stream_to_text_async(http_res)
662
- raise models.APIError(
663
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
664
- http_res.status_code,
665
- http_res_text,
666
- http_res,
667
- )
605
+ raise errors.APIError("Unexpected response received", http_res)
668
606
 
669
607
  def session_recording_stream(
670
608
  self,
@@ -742,29 +680,19 @@ class Sessions(BaseSDK):
742
680
  return http_res
743
681
  if utils.match_response(http_res, "422", "application/json"):
744
682
  http_res_text = utils.stream_to_text(http_res)
745
- response_data = utils.unmarshal_json(
746
- http_res_text, models.HTTPValidationErrorData
683
+ response_data = utils.unmarshal_json_response(
684
+ errors.HTTPValidationErrorData, http_res, http_res_text
747
685
  )
748
- raise models.HTTPValidationError(data=response_data)
686
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
749
687
  if utils.match_response(http_res, "4XX", "*"):
750
688
  http_res_text = utils.stream_to_text(http_res)
751
- raise models.APIError(
752
- "API error occurred", http_res.status_code, http_res_text, http_res
753
- )
689
+ raise errors.APIError("API error occurred", http_res, http_res_text)
754
690
  if utils.match_response(http_res, "5XX", "*"):
755
691
  http_res_text = utils.stream_to_text(http_res)
756
- raise models.APIError(
757
- "API error occurred", http_res.status_code, http_res_text, http_res
758
- )
692
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
693
 
760
- content_type = http_res.headers.get("Content-Type")
761
694
  http_res_text = utils.stream_to_text(http_res)
762
- raise models.APIError(
763
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
764
- http_res.status_code,
765
- http_res_text,
766
- http_res,
767
- )
695
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
768
696
 
769
697
  async def session_recording_stream_async(
770
698
  self,
@@ -842,26 +770,16 @@ class Sessions(BaseSDK):
842
770
  return http_res
843
771
  if utils.match_response(http_res, "422", "application/json"):
844
772
  http_res_text = await utils.stream_to_text_async(http_res)
845
- response_data = utils.unmarshal_json(
846
- http_res_text, models.HTTPValidationErrorData
773
+ response_data = utils.unmarshal_json_response(
774
+ errors.HTTPValidationErrorData, http_res, http_res_text
847
775
  )
848
- raise models.HTTPValidationError(data=response_data)
776
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
849
777
  if utils.match_response(http_res, "4XX", "*"):
850
778
  http_res_text = await utils.stream_to_text_async(http_res)
851
- raise models.APIError(
852
- "API error occurred", http_res.status_code, http_res_text, http_res
853
- )
779
+ raise errors.APIError("API error occurred", http_res, http_res_text)
854
780
  if utils.match_response(http_res, "5XX", "*"):
855
781
  http_res_text = await utils.stream_to_text_async(http_res)
856
- raise models.APIError(
857
- "API error occurred", http_res.status_code, http_res_text, http_res
858
- )
782
+ raise errors.APIError("API error occurred", http_res, http_res_text)
859
783
 
860
- content_type = http_res.headers.get("Content-Type")
861
784
  http_res_text = await utils.stream_to_text_async(http_res)
862
- raise models.APIError(
863
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
864
- http_res.status_code,
865
- http_res_text,
866
- http_res,
867
- )
785
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)