syllable-sdk 0.35.32__py3-none-any.whl → 0.35.34__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 +80 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +132 -329
  6. syllable_sdk/campaigns.py +74 -183
  7. syllable_sdk/channels.py +30 -73
  8. syllable_sdk/conversations.py +16 -37
  9. syllable_sdk/custom_messages.py +74 -183
  10. syllable_sdk/dashboards.py +64 -195
  11. syllable_sdk/data_sources.py +74 -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 +16 -37
  19. syllable_sdk/folders.py +116 -295
  20. syllable_sdk/full_summary.py +16 -37
  21. syllable_sdk/incidents.py +84 -215
  22. syllable_sdk/insights_sdk.py +16 -41
  23. syllable_sdk/insights_tools.py +96 -253
  24. syllable_sdk/language_groups.py +86 -215
  25. syllable_sdk/latency.py +16 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +44 -113
  28. syllable_sdk/organizations.py +52 -139
  29. syllable_sdk/permissions.py +12 -33
  30. syllable_sdk/prompts.py +94 -251
  31. syllable_sdk/roles.py +72 -181
  32. syllable_sdk/services.py +72 -185
  33. syllable_sdk/session_debug.py +44 -109
  34. syllable_sdk/session_labels.py +44 -109
  35. syllable_sdk/sessions.py +56 -141
  36. syllable_sdk/takeouts.py +36 -99
  37. syllable_sdk/targets.py +74 -187
  38. syllable_sdk/test.py +16 -37
  39. syllable_sdk/tools.py +72 -181
  40. syllable_sdk/transcript.py +18 -39
  41. syllable_sdk/twilio.py +44 -109
  42. syllable_sdk/users.py +94 -247
  43. syllable_sdk/utils/serializers.py +3 -2
  44. syllable_sdk/utils/unmarshal_json_response.py +24 -0
  45. syllable_sdk/v1.py +94 -247
  46. syllable_sdk/workflows.py +116 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.34.dist-info}/RECORD +49 -44
  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.34.dist-info}/WHEEL +0 -0
@@ -1,10 +1,11 @@
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
8
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
8
9
  from typing import Any, List, Mapping, Optional, Union, cast
9
10
 
10
11
 
@@ -83,31 +84,20 @@ class SessionLabels(BaseSDK):
83
84
 
84
85
  response_data: Any = None
85
86
  if utils.match_response(http_res, "200", "application/json"):
86
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
87
+ return unmarshal_json_response(models.SessionLabel, http_res)
87
88
  if utils.match_response(http_res, "422", "application/json"):
88
- response_data = utils.unmarshal_json(
89
- http_res.text, models.HTTPValidationErrorData
89
+ response_data = unmarshal_json_response(
90
+ errors.HTTPValidationErrorData, http_res
90
91
  )
91
- raise models.HTTPValidationError(data=response_data)
92
+ raise errors.HTTPValidationError(response_data, http_res)
92
93
  if utils.match_response(http_res, "4XX", "*"):
93
94
  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
- )
95
+ raise errors.APIError("API error occurred", http_res, http_res_text)
97
96
  if utils.match_response(http_res, "5XX", "*"):
98
97
  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
- )
98
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
99
 
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
- )
100
+ raise errors.APIError("Unexpected response received", http_res)
111
101
 
112
102
  async def get_by_id_async(
113
103
  self,
@@ -181,31 +171,20 @@ class SessionLabels(BaseSDK):
181
171
 
182
172
  response_data: Any = None
183
173
  if utils.match_response(http_res, "200", "application/json"):
184
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
174
+ return unmarshal_json_response(models.SessionLabel, http_res)
185
175
  if utils.match_response(http_res, "422", "application/json"):
186
- response_data = utils.unmarshal_json(
187
- http_res.text, models.HTTPValidationErrorData
176
+ response_data = unmarshal_json_response(
177
+ errors.HTTPValidationErrorData, http_res
188
178
  )
189
- raise models.HTTPValidationError(data=response_data)
179
+ raise errors.HTTPValidationError(response_data, http_res)
190
180
  if utils.match_response(http_res, "4XX", "*"):
191
181
  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
- )
182
+ raise errors.APIError("API error occurred", http_res, http_res_text)
195
183
  if utils.match_response(http_res, "5XX", "*"):
196
184
  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
- )
185
+ raise errors.APIError("API error occurred", http_res, http_res_text)
200
186
 
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
- )
187
+ raise errors.APIError("Unexpected response received", http_res)
209
188
 
210
189
  def create(
211
190
  self,
@@ -284,31 +263,20 @@ class SessionLabels(BaseSDK):
284
263
 
285
264
  response_data: Any = None
286
265
  if utils.match_response(http_res, "200", "application/json"):
287
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
266
+ return unmarshal_json_response(models.SessionLabel, http_res)
288
267
  if utils.match_response(http_res, "422", "application/json"):
289
- response_data = utils.unmarshal_json(
290
- http_res.text, models.HTTPValidationErrorData
268
+ response_data = unmarshal_json_response(
269
+ errors.HTTPValidationErrorData, http_res
291
270
  )
292
- raise models.HTTPValidationError(data=response_data)
271
+ raise errors.HTTPValidationError(response_data, http_res)
293
272
  if utils.match_response(http_res, "4XX", "*"):
294
273
  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
- )
274
+ raise errors.APIError("API error occurred", http_res, http_res_text)
298
275
  if utils.match_response(http_res, "5XX", "*"):
299
276
  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
- )
277
+ raise errors.APIError("API error occurred", http_res, http_res_text)
303
278
 
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
- )
279
+ raise errors.APIError("Unexpected response received", http_res)
312
280
 
313
281
  async def create_async(
314
282
  self,
@@ -387,31 +355,20 @@ class SessionLabels(BaseSDK):
387
355
 
388
356
  response_data: Any = None
389
357
  if utils.match_response(http_res, "200", "application/json"):
390
- return utils.unmarshal_json(http_res.text, models.SessionLabel)
358
+ return unmarshal_json_response(models.SessionLabel, http_res)
391
359
  if utils.match_response(http_res, "422", "application/json"):
392
- response_data = utils.unmarshal_json(
393
- http_res.text, models.HTTPValidationErrorData
360
+ response_data = unmarshal_json_response(
361
+ errors.HTTPValidationErrorData, http_res
394
362
  )
395
- raise models.HTTPValidationError(data=response_data)
363
+ raise errors.HTTPValidationError(response_data, http_res)
396
364
  if utils.match_response(http_res, "4XX", "*"):
397
365
  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
- )
366
+ raise errors.APIError("API error occurred", http_res, http_res_text)
401
367
  if utils.match_response(http_res, "5XX", "*"):
402
368
  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
- )
369
+ raise errors.APIError("API error occurred", http_res, http_res_text)
406
370
 
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
- )
371
+ raise errors.APIError("Unexpected response received", http_res)
415
372
 
416
373
  def list(
417
374
  self,
@@ -509,31 +466,20 @@ class SessionLabels(BaseSDK):
509
466
 
510
467
  response_data: Any = None
511
468
  if utils.match_response(http_res, "200", "application/json"):
512
- return utils.unmarshal_json(http_res.text, models.ListResponseSessionLabel)
469
+ return unmarshal_json_response(models.ListResponseSessionLabel, http_res)
513
470
  if utils.match_response(http_res, "422", "application/json"):
514
- response_data = utils.unmarshal_json(
515
- http_res.text, models.HTTPValidationErrorData
471
+ response_data = unmarshal_json_response(
472
+ errors.HTTPValidationErrorData, http_res
516
473
  )
517
- raise models.HTTPValidationError(data=response_data)
474
+ raise errors.HTTPValidationError(response_data, http_res)
518
475
  if utils.match_response(http_res, "4XX", "*"):
519
476
  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
- )
477
+ raise errors.APIError("API error occurred", http_res, http_res_text)
523
478
  if utils.match_response(http_res, "5XX", "*"):
524
479
  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
- )
480
+ raise errors.APIError("API error occurred", http_res, http_res_text)
528
481
 
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
- )
482
+ raise errors.APIError("Unexpected response received", http_res)
537
483
 
538
484
  async def list_async(
539
485
  self,
@@ -631,28 +577,17 @@ class SessionLabels(BaseSDK):
631
577
 
632
578
  response_data: Any = None
633
579
  if utils.match_response(http_res, "200", "application/json"):
634
- return utils.unmarshal_json(http_res.text, models.ListResponseSessionLabel)
580
+ return unmarshal_json_response(models.ListResponseSessionLabel, http_res)
635
581
  if utils.match_response(http_res, "422", "application/json"):
636
- response_data = utils.unmarshal_json(
637
- http_res.text, models.HTTPValidationErrorData
582
+ response_data = unmarshal_json_response(
583
+ errors.HTTPValidationErrorData, http_res
638
584
  )
639
- raise models.HTTPValidationError(data=response_data)
585
+ raise errors.HTTPValidationError(response_data, http_res)
640
586
  if utils.match_response(http_res, "4XX", "*"):
641
587
  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
- )
588
+ raise errors.APIError("API error occurred", http_res, http_res_text)
645
589
  if utils.match_response(http_res, "5XX", "*"):
646
590
  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
- )
591
+ raise errors.APIError("API error occurred", http_res, http_res_text)
650
592
 
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
- )
593
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/sessions.py CHANGED
@@ -3,13 +3,14 @@
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
10
10
  from syllable_sdk.transcript import Transcript
11
11
  from syllable_sdk.types import OptionalNullable, UNSET
12
12
  from syllable_sdk.utils import get_security_from_env
13
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
13
14
  from typing import Any, List, Mapping, Optional
14
15
 
15
16
 
@@ -126,31 +127,20 @@ class Sessions(BaseSDK):
126
127
 
127
128
  response_data: Any = None
128
129
  if utils.match_response(http_res, "200", "application/json"):
129
- return utils.unmarshal_json(http_res.text, models.ListResponseSession)
130
+ return unmarshal_json_response(models.ListResponseSession, http_res)
130
131
  if utils.match_response(http_res, "422", "application/json"):
131
- response_data = utils.unmarshal_json(
132
- http_res.text, models.HTTPValidationErrorData
132
+ response_data = unmarshal_json_response(
133
+ errors.HTTPValidationErrorData, http_res
133
134
  )
134
- raise models.HTTPValidationError(data=response_data)
135
+ raise errors.HTTPValidationError(response_data, http_res)
135
136
  if utils.match_response(http_res, "4XX", "*"):
136
137
  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
- )
138
+ raise errors.APIError("API error occurred", http_res, http_res_text)
140
139
  if utils.match_response(http_res, "5XX", "*"):
141
140
  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
- )
141
+ raise errors.APIError("API error occurred", http_res, http_res_text)
145
142
 
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
- )
143
+ raise errors.APIError("Unexpected response received", http_res)
154
144
 
155
145
  async def list_async(
156
146
  self,
@@ -248,31 +238,20 @@ class Sessions(BaseSDK):
248
238
 
249
239
  response_data: Any = None
250
240
  if utils.match_response(http_res, "200", "application/json"):
251
- return utils.unmarshal_json(http_res.text, models.ListResponseSession)
241
+ return unmarshal_json_response(models.ListResponseSession, http_res)
252
242
  if utils.match_response(http_res, "422", "application/json"):
253
- response_data = utils.unmarshal_json(
254
- http_res.text, models.HTTPValidationErrorData
243
+ response_data = unmarshal_json_response(
244
+ errors.HTTPValidationErrorData, http_res
255
245
  )
256
- raise models.HTTPValidationError(data=response_data)
246
+ raise errors.HTTPValidationError(response_data, http_res)
257
247
  if utils.match_response(http_res, "4XX", "*"):
258
248
  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
- )
249
+ raise errors.APIError("API error occurred", http_res, http_res_text)
262
250
  if utils.match_response(http_res, "5XX", "*"):
263
251
  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
- )
252
+ raise errors.APIError("API error occurred", http_res, http_res_text)
267
253
 
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
- )
254
+ raise errors.APIError("Unexpected response received", http_res)
276
255
 
277
256
  def get_by_id(
278
257
  self,
@@ -346,31 +325,20 @@ class Sessions(BaseSDK):
346
325
 
347
326
  response_data: Any = None
348
327
  if utils.match_response(http_res, "200", "application/json"):
349
- return utils.unmarshal_json(http_res.text, models.Session)
328
+ return unmarshal_json_response(models.Session, http_res)
350
329
  if utils.match_response(http_res, "422", "application/json"):
351
- response_data = utils.unmarshal_json(
352
- http_res.text, models.HTTPValidationErrorData
330
+ response_data = unmarshal_json_response(
331
+ errors.HTTPValidationErrorData, http_res
353
332
  )
354
- raise models.HTTPValidationError(data=response_data)
333
+ raise errors.HTTPValidationError(response_data, http_res)
355
334
  if utils.match_response(http_res, "4XX", "*"):
356
335
  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
- )
336
+ raise errors.APIError("API error occurred", http_res, http_res_text)
360
337
  if utils.match_response(http_res, "5XX", "*"):
361
338
  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
- )
339
+ raise errors.APIError("API error occurred", http_res, http_res_text)
365
340
 
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
- )
341
+ raise errors.APIError("Unexpected response received", http_res)
374
342
 
375
343
  async def get_by_id_async(
376
344
  self,
@@ -444,31 +412,20 @@ class Sessions(BaseSDK):
444
412
 
445
413
  response_data: Any = None
446
414
  if utils.match_response(http_res, "200", "application/json"):
447
- return utils.unmarshal_json(http_res.text, models.Session)
415
+ return unmarshal_json_response(models.Session, http_res)
448
416
  if utils.match_response(http_res, "422", "application/json"):
449
- response_data = utils.unmarshal_json(
450
- http_res.text, models.HTTPValidationErrorData
417
+ response_data = unmarshal_json_response(
418
+ errors.HTTPValidationErrorData, http_res
451
419
  )
452
- raise models.HTTPValidationError(data=response_data)
420
+ raise errors.HTTPValidationError(response_data, http_res)
453
421
  if utils.match_response(http_res, "4XX", "*"):
454
422
  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
- )
423
+ raise errors.APIError("API error occurred", http_res, http_res_text)
458
424
  if utils.match_response(http_res, "5XX", "*"):
459
425
  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
- )
426
+ raise errors.APIError("API error occurred", http_res, http_res_text)
463
427
 
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
- )
428
+ raise errors.APIError("Unexpected response received", http_res)
472
429
 
473
430
  def generate_session_recording_urls(
474
431
  self,
@@ -542,31 +499,20 @@ class Sessions(BaseSDK):
542
499
 
543
500
  response_data: Any = None
544
501
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.SessionRecordingResponse)
502
+ return unmarshal_json_response(models.SessionRecordingResponse, http_res)
546
503
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
504
+ response_data = unmarshal_json_response(
505
+ errors.HTTPValidationErrorData, http_res
549
506
  )
550
- raise models.HTTPValidationError(data=response_data)
507
+ raise errors.HTTPValidationError(response_data, http_res)
551
508
  if utils.match_response(http_res, "4XX", "*"):
552
509
  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
- )
510
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
511
  if utils.match_response(http_res, "5XX", "*"):
557
512
  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
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
514
 
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
- )
515
+ raise errors.APIError("Unexpected response received", http_res)
570
516
 
571
517
  async def generate_session_recording_urls_async(
572
518
  self,
@@ -640,31 +586,20 @@ class Sessions(BaseSDK):
640
586
 
641
587
  response_data: Any = None
642
588
  if utils.match_response(http_res, "200", "application/json"):
643
- return utils.unmarshal_json(http_res.text, models.SessionRecordingResponse)
589
+ return unmarshal_json_response(models.SessionRecordingResponse, http_res)
644
590
  if utils.match_response(http_res, "422", "application/json"):
645
- response_data = utils.unmarshal_json(
646
- http_res.text, models.HTTPValidationErrorData
591
+ response_data = unmarshal_json_response(
592
+ errors.HTTPValidationErrorData, http_res
647
593
  )
648
- raise models.HTTPValidationError(data=response_data)
594
+ raise errors.HTTPValidationError(response_data, http_res)
649
595
  if utils.match_response(http_res, "4XX", "*"):
650
596
  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
- )
597
+ raise errors.APIError("API error occurred", http_res, http_res_text)
654
598
  if utils.match_response(http_res, "5XX", "*"):
655
599
  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
- )
600
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
601
 
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
- )
602
+ raise errors.APIError("Unexpected response received", http_res)
668
603
 
669
604
  def session_recording_stream(
670
605
  self,
@@ -742,29 +677,19 @@ class Sessions(BaseSDK):
742
677
  return http_res
743
678
  if utils.match_response(http_res, "422", "application/json"):
744
679
  http_res_text = utils.stream_to_text(http_res)
745
- response_data = utils.unmarshal_json(
746
- http_res_text, models.HTTPValidationErrorData
680
+ response_data = unmarshal_json_response(
681
+ errors.HTTPValidationErrorData, http_res, http_res_text
747
682
  )
748
- raise models.HTTPValidationError(data=response_data)
683
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
749
684
  if utils.match_response(http_res, "4XX", "*"):
750
685
  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
- )
686
+ raise errors.APIError("API error occurred", http_res, http_res_text)
754
687
  if utils.match_response(http_res, "5XX", "*"):
755
688
  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
- )
689
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
690
 
760
- content_type = http_res.headers.get("Content-Type")
761
691
  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
- )
692
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
768
693
 
769
694
  async def session_recording_stream_async(
770
695
  self,
@@ -842,26 +767,16 @@ class Sessions(BaseSDK):
842
767
  return http_res
843
768
  if utils.match_response(http_res, "422", "application/json"):
844
769
  http_res_text = await utils.stream_to_text_async(http_res)
845
- response_data = utils.unmarshal_json(
846
- http_res_text, models.HTTPValidationErrorData
770
+ response_data = unmarshal_json_response(
771
+ errors.HTTPValidationErrorData, http_res, http_res_text
847
772
  )
848
- raise models.HTTPValidationError(data=response_data)
773
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
849
774
  if utils.match_response(http_res, "4XX", "*"):
850
775
  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
- )
776
+ raise errors.APIError("API error occurred", http_res, http_res_text)
854
777
  if utils.match_response(http_res, "5XX", "*"):
855
778
  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
- )
779
+ raise errors.APIError("API error occurred", http_res, http_res_text)
859
780
 
860
- content_type = http_res.headers.get("Content-Type")
861
781
  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
- )
782
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)