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