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
syllable_sdk/v1.py CHANGED
@@ -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
@@ -107,31 +107,22 @@ class V1(BaseSDK):
107
107
 
108
108
  response_data: Any = None
109
109
  if utils.match_response(http_res, "200", "application/json"):
110
- return utils.unmarshal_json(http_res.text, models.ListResponseUserResponse)
110
+ return utils.unmarshal_json_response(
111
+ models.ListResponseUserResponse, http_res
112
+ )
111
113
  if utils.match_response(http_res, "422", "application/json"):
112
- response_data = utils.unmarshal_json(
113
- http_res.text, models.HTTPValidationErrorData
114
+ response_data = utils.unmarshal_json_response(
115
+ errors.HTTPValidationErrorData, http_res
114
116
  )
115
- raise models.HTTPValidationError(data=response_data)
117
+ raise errors.HTTPValidationError(response_data, http_res)
116
118
  if utils.match_response(http_res, "4XX", "*"):
117
119
  http_res_text = utils.stream_to_text(http_res)
118
- raise models.APIError(
119
- "API error occurred", http_res.status_code, http_res_text, http_res
120
- )
120
+ raise errors.APIError("API error occurred", http_res, http_res_text)
121
121
  if utils.match_response(http_res, "5XX", "*"):
122
122
  http_res_text = utils.stream_to_text(http_res)
123
- raise models.APIError(
124
- "API error occurred", http_res.status_code, http_res_text, http_res
125
- )
123
+ raise errors.APIError("API error occurred", http_res, http_res_text)
126
124
 
127
- content_type = http_res.headers.get("Content-Type")
128
- http_res_text = utils.stream_to_text(http_res)
129
- raise models.APIError(
130
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
131
- http_res.status_code,
132
- http_res_text,
133
- http_res,
134
- )
125
+ raise errors.APIError("Unexpected response received", http_res)
135
126
 
136
127
  async def list_async(
137
128
  self,
@@ -231,31 +222,22 @@ class V1(BaseSDK):
231
222
 
232
223
  response_data: Any = None
233
224
  if utils.match_response(http_res, "200", "application/json"):
234
- return utils.unmarshal_json(http_res.text, models.ListResponseUserResponse)
225
+ return utils.unmarshal_json_response(
226
+ models.ListResponseUserResponse, http_res
227
+ )
235
228
  if utils.match_response(http_res, "422", "application/json"):
236
- response_data = utils.unmarshal_json(
237
- http_res.text, models.HTTPValidationErrorData
229
+ response_data = utils.unmarshal_json_response(
230
+ errors.HTTPValidationErrorData, http_res
238
231
  )
239
- raise models.HTTPValidationError(data=response_data)
232
+ raise errors.HTTPValidationError(response_data, http_res)
240
233
  if utils.match_response(http_res, "4XX", "*"):
241
234
  http_res_text = await utils.stream_to_text_async(http_res)
242
- raise models.APIError(
243
- "API error occurred", http_res.status_code, http_res_text, http_res
244
- )
235
+ raise errors.APIError("API error occurred", http_res, http_res_text)
245
236
  if utils.match_response(http_res, "5XX", "*"):
246
237
  http_res_text = await utils.stream_to_text_async(http_res)
247
- raise models.APIError(
248
- "API error occurred", http_res.status_code, http_res_text, http_res
249
- )
238
+ raise errors.APIError("API error occurred", http_res, http_res_text)
250
239
 
251
- content_type = http_res.headers.get("Content-Type")
252
- http_res_text = await utils.stream_to_text_async(http_res)
253
- raise models.APIError(
254
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
255
- http_res.status_code,
256
- http_res_text,
257
- http_res,
258
- )
240
+ raise errors.APIError("Unexpected response received", http_res)
259
241
 
260
242
  def create(
261
243
  self,
@@ -334,31 +316,20 @@ class V1(BaseSDK):
334
316
 
335
317
  response_data: Any = None
336
318
  if utils.match_response(http_res, "200", "application/json"):
337
- return utils.unmarshal_json(http_res.text, models.UserResponse)
319
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
338
320
  if utils.match_response(http_res, "422", "application/json"):
339
- response_data = utils.unmarshal_json(
340
- http_res.text, models.HTTPValidationErrorData
321
+ response_data = utils.unmarshal_json_response(
322
+ errors.HTTPValidationErrorData, http_res
341
323
  )
342
- raise models.HTTPValidationError(data=response_data)
324
+ raise errors.HTTPValidationError(response_data, http_res)
343
325
  if utils.match_response(http_res, "4XX", "*"):
344
326
  http_res_text = utils.stream_to_text(http_res)
345
- raise models.APIError(
346
- "API error occurred", http_res.status_code, http_res_text, http_res
347
- )
327
+ raise errors.APIError("API error occurred", http_res, http_res_text)
348
328
  if utils.match_response(http_res, "5XX", "*"):
349
329
  http_res_text = utils.stream_to_text(http_res)
350
- raise models.APIError(
351
- "API error occurred", http_res.status_code, http_res_text, http_res
352
- )
330
+ raise errors.APIError("API error occurred", http_res, http_res_text)
353
331
 
354
- content_type = http_res.headers.get("Content-Type")
355
- http_res_text = utils.stream_to_text(http_res)
356
- raise models.APIError(
357
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
358
- http_res.status_code,
359
- http_res_text,
360
- http_res,
361
- )
332
+ raise errors.APIError("Unexpected response received", http_res)
362
333
 
363
334
  async def create_async(
364
335
  self,
@@ -437,31 +408,20 @@ class V1(BaseSDK):
437
408
 
438
409
  response_data: Any = None
439
410
  if utils.match_response(http_res, "200", "application/json"):
440
- return utils.unmarshal_json(http_res.text, models.UserResponse)
411
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
441
412
  if utils.match_response(http_res, "422", "application/json"):
442
- response_data = utils.unmarshal_json(
443
- http_res.text, models.HTTPValidationErrorData
413
+ response_data = utils.unmarshal_json_response(
414
+ errors.HTTPValidationErrorData, http_res
444
415
  )
445
- raise models.HTTPValidationError(data=response_data)
416
+ raise errors.HTTPValidationError(response_data, http_res)
446
417
  if utils.match_response(http_res, "4XX", "*"):
447
418
  http_res_text = await utils.stream_to_text_async(http_res)
448
- raise models.APIError(
449
- "API error occurred", http_res.status_code, http_res_text, http_res
450
- )
419
+ raise errors.APIError("API error occurred", http_res, http_res_text)
451
420
  if utils.match_response(http_res, "5XX", "*"):
452
421
  http_res_text = await utils.stream_to_text_async(http_res)
453
- raise models.APIError(
454
- "API error occurred", http_res.status_code, http_res_text, http_res
455
- )
422
+ raise errors.APIError("API error occurred", http_res, http_res_text)
456
423
 
457
- content_type = http_res.headers.get("Content-Type")
458
- http_res_text = await utils.stream_to_text_async(http_res)
459
- raise models.APIError(
460
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
461
- http_res.status_code,
462
- http_res_text,
463
- http_res,
464
- )
424
+ raise errors.APIError("Unexpected response received", http_res)
465
425
 
466
426
  def update(
467
427
  self,
@@ -540,31 +500,20 @@ class V1(BaseSDK):
540
500
 
541
501
  response_data: Any = None
542
502
  if utils.match_response(http_res, "200", "application/json"):
543
- return utils.unmarshal_json(http_res.text, models.UserResponse)
503
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
544
504
  if utils.match_response(http_res, "422", "application/json"):
545
- response_data = utils.unmarshal_json(
546
- http_res.text, models.HTTPValidationErrorData
505
+ response_data = utils.unmarshal_json_response(
506
+ errors.HTTPValidationErrorData, http_res
547
507
  )
548
- raise models.HTTPValidationError(data=response_data)
508
+ raise errors.HTTPValidationError(response_data, http_res)
549
509
  if utils.match_response(http_res, "4XX", "*"):
550
510
  http_res_text = utils.stream_to_text(http_res)
551
- raise models.APIError(
552
- "API error occurred", http_res.status_code, http_res_text, http_res
553
- )
511
+ raise errors.APIError("API error occurred", http_res, http_res_text)
554
512
  if utils.match_response(http_res, "5XX", "*"):
555
513
  http_res_text = utils.stream_to_text(http_res)
556
- raise models.APIError(
557
- "API error occurred", http_res.status_code, http_res_text, http_res
558
- )
514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
559
515
 
560
- content_type = http_res.headers.get("Content-Type")
561
- http_res_text = utils.stream_to_text(http_res)
562
- raise models.APIError(
563
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
564
- http_res.status_code,
565
- http_res_text,
566
- http_res,
567
- )
516
+ raise errors.APIError("Unexpected response received", http_res)
568
517
 
569
518
  async def update_async(
570
519
  self,
@@ -643,31 +592,20 @@ class V1(BaseSDK):
643
592
 
644
593
  response_data: Any = None
645
594
  if utils.match_response(http_res, "200", "application/json"):
646
- return utils.unmarshal_json(http_res.text, models.UserResponse)
595
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
647
596
  if utils.match_response(http_res, "422", "application/json"):
648
- response_data = utils.unmarshal_json(
649
- http_res.text, models.HTTPValidationErrorData
597
+ response_data = utils.unmarshal_json_response(
598
+ errors.HTTPValidationErrorData, http_res
650
599
  )
651
- raise models.HTTPValidationError(data=response_data)
600
+ raise errors.HTTPValidationError(response_data, http_res)
652
601
  if utils.match_response(http_res, "4XX", "*"):
653
602
  http_res_text = await utils.stream_to_text_async(http_res)
654
- raise models.APIError(
655
- "API error occurred", http_res.status_code, http_res_text, http_res
656
- )
603
+ raise errors.APIError("API error occurred", http_res, http_res_text)
657
604
  if utils.match_response(http_res, "5XX", "*"):
658
605
  http_res_text = await utils.stream_to_text_async(http_res)
659
- raise models.APIError(
660
- "API error occurred", http_res.status_code, http_res_text, http_res
661
- )
606
+ raise errors.APIError("API error occurred", http_res, http_res_text)
662
607
 
663
- content_type = http_res.headers.get("Content-Type")
664
- http_res_text = await utils.stream_to_text_async(http_res)
665
- raise models.APIError(
666
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
667
- http_res.status_code,
668
- http_res_text,
669
- http_res,
670
- )
608
+ raise errors.APIError("Unexpected response received", http_res)
671
609
 
672
610
  def delete(
673
611
  self,
@@ -746,31 +684,20 @@ class V1(BaseSDK):
746
684
 
747
685
  response_data: Any = None
748
686
  if utils.match_response(http_res, "200", "application/json"):
749
- return utils.unmarshal_json(http_res.text, Any)
687
+ return utils.unmarshal_json_response(Any, http_res)
750
688
  if utils.match_response(http_res, "422", "application/json"):
751
- response_data = utils.unmarshal_json(
752
- http_res.text, models.HTTPValidationErrorData
689
+ response_data = utils.unmarshal_json_response(
690
+ errors.HTTPValidationErrorData, http_res
753
691
  )
754
- raise models.HTTPValidationError(data=response_data)
692
+ raise errors.HTTPValidationError(response_data, http_res)
755
693
  if utils.match_response(http_res, "4XX", "*"):
756
694
  http_res_text = utils.stream_to_text(http_res)
757
- raise models.APIError(
758
- "API error occurred", http_res.status_code, http_res_text, http_res
759
- )
695
+ raise errors.APIError("API error occurred", http_res, http_res_text)
760
696
  if utils.match_response(http_res, "5XX", "*"):
761
697
  http_res_text = utils.stream_to_text(http_res)
762
- raise models.APIError(
763
- "API error occurred", http_res.status_code, http_res_text, http_res
764
- )
698
+ raise errors.APIError("API error occurred", http_res, http_res_text)
765
699
 
766
- content_type = http_res.headers.get("Content-Type")
767
- http_res_text = utils.stream_to_text(http_res)
768
- raise models.APIError(
769
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
770
- http_res.status_code,
771
- http_res_text,
772
- http_res,
773
- )
700
+ raise errors.APIError("Unexpected response received", http_res)
774
701
 
775
702
  async def delete_async(
776
703
  self,
@@ -849,31 +776,20 @@ class V1(BaseSDK):
849
776
 
850
777
  response_data: Any = None
851
778
  if utils.match_response(http_res, "200", "application/json"):
852
- return utils.unmarshal_json(http_res.text, Any)
779
+ return utils.unmarshal_json_response(Any, http_res)
853
780
  if utils.match_response(http_res, "422", "application/json"):
854
- response_data = utils.unmarshal_json(
855
- http_res.text, models.HTTPValidationErrorData
781
+ response_data = utils.unmarshal_json_response(
782
+ errors.HTTPValidationErrorData, http_res
856
783
  )
857
- raise models.HTTPValidationError(data=response_data)
784
+ raise errors.HTTPValidationError(response_data, http_res)
858
785
  if utils.match_response(http_res, "4XX", "*"):
859
786
  http_res_text = await utils.stream_to_text_async(http_res)
860
- raise models.APIError(
861
- "API error occurred", http_res.status_code, http_res_text, http_res
862
- )
787
+ raise errors.APIError("API error occurred", http_res, http_res_text)
863
788
  if utils.match_response(http_res, "5XX", "*"):
864
789
  http_res_text = await utils.stream_to_text_async(http_res)
865
- raise models.APIError(
866
- "API error occurred", http_res.status_code, http_res_text, http_res
867
- )
790
+ raise errors.APIError("API error occurred", http_res, http_res_text)
868
791
 
869
- content_type = http_res.headers.get("Content-Type")
870
- http_res_text = await utils.stream_to_text_async(http_res)
871
- raise models.APIError(
872
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
873
- http_res.status_code,
874
- http_res_text,
875
- http_res,
876
- )
792
+ raise errors.APIError("Unexpected response received", http_res)
877
793
 
878
794
  def users_get_by_email(
879
795
  self,
@@ -949,31 +865,20 @@ class V1(BaseSDK):
949
865
 
950
866
  response_data: Any = None
951
867
  if utils.match_response(http_res, "200", "application/json"):
952
- return utils.unmarshal_json(http_res.text, models.UserResponse)
868
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
953
869
  if utils.match_response(http_res, "422", "application/json"):
954
- response_data = utils.unmarshal_json(
955
- http_res.text, models.HTTPValidationErrorData
870
+ response_data = utils.unmarshal_json_response(
871
+ errors.HTTPValidationErrorData, http_res
956
872
  )
957
- raise models.HTTPValidationError(data=response_data)
873
+ raise errors.HTTPValidationError(response_data, http_res)
958
874
  if utils.match_response(http_res, "4XX", "*"):
959
875
  http_res_text = utils.stream_to_text(http_res)
960
- raise models.APIError(
961
- "API error occurred", http_res.status_code, http_res_text, http_res
962
- )
876
+ raise errors.APIError("API error occurred", http_res, http_res_text)
963
877
  if utils.match_response(http_res, "5XX", "*"):
964
878
  http_res_text = utils.stream_to_text(http_res)
965
- raise models.APIError(
966
- "API error occurred", http_res.status_code, http_res_text, http_res
967
- )
879
+ raise errors.APIError("API error occurred", http_res, http_res_text)
968
880
 
969
- content_type = http_res.headers.get("Content-Type")
970
- http_res_text = utils.stream_to_text(http_res)
971
- raise models.APIError(
972
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
973
- http_res.status_code,
974
- http_res_text,
975
- http_res,
976
- )
881
+ raise errors.APIError("Unexpected response received", http_res)
977
882
 
978
883
  async def users_get_by_email_async(
979
884
  self,
@@ -1049,31 +954,20 @@ class V1(BaseSDK):
1049
954
 
1050
955
  response_data: Any = None
1051
956
  if utils.match_response(http_res, "200", "application/json"):
1052
- return utils.unmarshal_json(http_res.text, models.UserResponse)
957
+ return utils.unmarshal_json_response(models.UserResponse, http_res)
1053
958
  if utils.match_response(http_res, "422", "application/json"):
1054
- response_data = utils.unmarshal_json(
1055
- http_res.text, models.HTTPValidationErrorData
959
+ response_data = utils.unmarshal_json_response(
960
+ errors.HTTPValidationErrorData, http_res
1056
961
  )
1057
- raise models.HTTPValidationError(data=response_data)
962
+ raise errors.HTTPValidationError(response_data, http_res)
1058
963
  if utils.match_response(http_res, "4XX", "*"):
1059
964
  http_res_text = await utils.stream_to_text_async(http_res)
1060
- raise models.APIError(
1061
- "API error occurred", http_res.status_code, http_res_text, http_res
1062
- )
965
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1063
966
  if utils.match_response(http_res, "5XX", "*"):
1064
967
  http_res_text = await utils.stream_to_text_async(http_res)
1065
- raise models.APIError(
1066
- "API error occurred", http_res.status_code, http_res_text, http_res
1067
- )
968
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1068
969
 
1069
- content_type = http_res.headers.get("Content-Type")
1070
- http_res_text = await utils.stream_to_text_async(http_res)
1071
- raise models.APIError(
1072
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1073
- http_res.status_code,
1074
- http_res_text,
1075
- http_res,
1076
- )
970
+ raise errors.APIError("Unexpected response received", http_res)
1077
971
 
1078
972
  def users_send_email(
1079
973
  self,
@@ -1149,31 +1043,20 @@ class V1(BaseSDK):
1149
1043
 
1150
1044
  response_data: Any = None
1151
1045
  if utils.match_response(http_res, "200", "application/json"):
1152
- return utils.unmarshal_json(http_res.text, Any)
1046
+ return utils.unmarshal_json_response(Any, http_res)
1153
1047
  if utils.match_response(http_res, "422", "application/json"):
1154
- response_data = utils.unmarshal_json(
1155
- http_res.text, models.HTTPValidationErrorData
1048
+ response_data = utils.unmarshal_json_response(
1049
+ errors.HTTPValidationErrorData, http_res
1156
1050
  )
1157
- raise models.HTTPValidationError(data=response_data)
1051
+ raise errors.HTTPValidationError(response_data, http_res)
1158
1052
  if utils.match_response(http_res, "4XX", "*"):
1159
1053
  http_res_text = utils.stream_to_text(http_res)
1160
- raise models.APIError(
1161
- "API error occurred", http_res.status_code, http_res_text, http_res
1162
- )
1054
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1163
1055
  if utils.match_response(http_res, "5XX", "*"):
1164
1056
  http_res_text = utils.stream_to_text(http_res)
1165
- raise models.APIError(
1166
- "API error occurred", http_res.status_code, http_res_text, http_res
1167
- )
1057
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1168
1058
 
1169
- content_type = http_res.headers.get("Content-Type")
1170
- http_res_text = utils.stream_to_text(http_res)
1171
- raise models.APIError(
1172
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1173
- http_res.status_code,
1174
- http_res_text,
1175
- http_res,
1176
- )
1059
+ raise errors.APIError("Unexpected response received", http_res)
1177
1060
 
1178
1061
  async def users_send_email_async(
1179
1062
  self,
@@ -1249,31 +1132,20 @@ class V1(BaseSDK):
1249
1132
 
1250
1133
  response_data: Any = None
1251
1134
  if utils.match_response(http_res, "200", "application/json"):
1252
- return utils.unmarshal_json(http_res.text, Any)
1135
+ return utils.unmarshal_json_response(Any, http_res)
1253
1136
  if utils.match_response(http_res, "422", "application/json"):
1254
- response_data = utils.unmarshal_json(
1255
- http_res.text, models.HTTPValidationErrorData
1137
+ response_data = utils.unmarshal_json_response(
1138
+ errors.HTTPValidationErrorData, http_res
1256
1139
  )
1257
- raise models.HTTPValidationError(data=response_data)
1140
+ raise errors.HTTPValidationError(response_data, http_res)
1258
1141
  if utils.match_response(http_res, "4XX", "*"):
1259
1142
  http_res_text = await utils.stream_to_text_async(http_res)
1260
- raise models.APIError(
1261
- "API error occurred", http_res.status_code, http_res_text, http_res
1262
- )
1143
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1263
1144
  if utils.match_response(http_res, "5XX", "*"):
1264
1145
  http_res_text = await utils.stream_to_text_async(http_res)
1265
- raise models.APIError(
1266
- "API error occurred", http_res.status_code, http_res_text, http_res
1267
- )
1146
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1268
1147
 
1269
- content_type = http_res.headers.get("Content-Type")
1270
- http_res_text = await utils.stream_to_text_async(http_res)
1271
- raise models.APIError(
1272
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1273
- http_res.status_code,
1274
- http_res_text,
1275
- http_res,
1276
- )
1148
+ raise errors.APIError("Unexpected response received", http_res)
1277
1149
 
1278
1150
  def users_delete_account(
1279
1151
  self,
@@ -1342,26 +1214,15 @@ class V1(BaseSDK):
1342
1214
  )
1343
1215
 
1344
1216
  if utils.match_response(http_res, "200", "application/json"):
1345
- return utils.unmarshal_json(http_res.text, Any)
1217
+ return utils.unmarshal_json_response(Any, http_res)
1346
1218
  if utils.match_response(http_res, "4XX", "*"):
1347
1219
  http_res_text = utils.stream_to_text(http_res)
1348
- raise models.APIError(
1349
- "API error occurred", http_res.status_code, http_res_text, http_res
1350
- )
1220
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1351
1221
  if utils.match_response(http_res, "5XX", "*"):
1352
1222
  http_res_text = utils.stream_to_text(http_res)
1353
- raise models.APIError(
1354
- "API error occurred", http_res.status_code, http_res_text, http_res
1355
- )
1223
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1356
1224
 
1357
- content_type = http_res.headers.get("Content-Type")
1358
- http_res_text = utils.stream_to_text(http_res)
1359
- raise models.APIError(
1360
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1361
- http_res.status_code,
1362
- http_res_text,
1363
- http_res,
1364
- )
1225
+ raise errors.APIError("Unexpected response received", http_res)
1365
1226
 
1366
1227
  async def users_delete_account_async(
1367
1228
  self,
@@ -1430,23 +1291,12 @@ class V1(BaseSDK):
1430
1291
  )
1431
1292
 
1432
1293
  if utils.match_response(http_res, "200", "application/json"):
1433
- return utils.unmarshal_json(http_res.text, Any)
1294
+ return utils.unmarshal_json_response(Any, http_res)
1434
1295
  if utils.match_response(http_res, "4XX", "*"):
1435
1296
  http_res_text = await utils.stream_to_text_async(http_res)
1436
- raise models.APIError(
1437
- "API error occurred", http_res.status_code, http_res_text, http_res
1438
- )
1297
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1439
1298
  if utils.match_response(http_res, "5XX", "*"):
1440
1299
  http_res_text = await utils.stream_to_text_async(http_res)
1441
- raise models.APIError(
1442
- "API error occurred", http_res.status_code, http_res_text, http_res
1443
- )
1300
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1444
1301
 
1445
- content_type = http_res.headers.get("Content-Type")
1446
- http_res_text = await utils.stream_to_text_async(http_res)
1447
- raise models.APIError(
1448
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1449
- http_res.status_code,
1450
- http_res_text,
1451
- http_res,
1452
- )
1302
+ raise errors.APIError("Unexpected response received", http_res)