syllable-sdk 0.35.31__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.31.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.31.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.31.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
syllable_sdk/batches.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,33 +107,22 @@ class Batches(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(
111
- http_res.text, models.ListResponseCommunicationBatch
110
+ return utils.unmarshal_json_response(
111
+ models.ListResponseCommunicationBatch, http_res
112
112
  )
113
113
  if utils.match_response(http_res, "422", "application/json"):
114
- response_data = utils.unmarshal_json(
115
- http_res.text, models.HTTPValidationErrorData
114
+ response_data = utils.unmarshal_json_response(
115
+ errors.HTTPValidationErrorData, http_res
116
116
  )
117
- raise models.HTTPValidationError(data=response_data)
117
+ raise errors.HTTPValidationError(response_data, http_res)
118
118
  if utils.match_response(http_res, "4XX", "*"):
119
119
  http_res_text = utils.stream_to_text(http_res)
120
- raise models.APIError(
121
- "API error occurred", http_res.status_code, http_res_text, http_res
122
- )
120
+ raise errors.APIError("API error occurred", http_res, http_res_text)
123
121
  if utils.match_response(http_res, "5XX", "*"):
124
122
  http_res_text = utils.stream_to_text(http_res)
125
- raise models.APIError(
126
- "API error occurred", http_res.status_code, http_res_text, http_res
127
- )
123
+ raise errors.APIError("API error occurred", http_res, http_res_text)
128
124
 
129
- content_type = http_res.headers.get("Content-Type")
130
- http_res_text = utils.stream_to_text(http_res)
131
- raise models.APIError(
132
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
133
- http_res.status_code,
134
- http_res_text,
135
- http_res,
136
- )
125
+ raise errors.APIError("Unexpected response received", http_res)
137
126
 
138
127
  async def list_async(
139
128
  self,
@@ -231,33 +220,22 @@ class Batches(BaseSDK):
231
220
 
232
221
  response_data: Any = None
233
222
  if utils.match_response(http_res, "200", "application/json"):
234
- return utils.unmarshal_json(
235
- http_res.text, models.ListResponseCommunicationBatch
223
+ return utils.unmarshal_json_response(
224
+ models.ListResponseCommunicationBatch, http_res
236
225
  )
237
226
  if utils.match_response(http_res, "422", "application/json"):
238
- response_data = utils.unmarshal_json(
239
- http_res.text, models.HTTPValidationErrorData
227
+ response_data = utils.unmarshal_json_response(
228
+ errors.HTTPValidationErrorData, http_res
240
229
  )
241
- raise models.HTTPValidationError(data=response_data)
230
+ raise errors.HTTPValidationError(response_data, http_res)
242
231
  if utils.match_response(http_res, "4XX", "*"):
243
232
  http_res_text = await utils.stream_to_text_async(http_res)
244
- raise models.APIError(
245
- "API error occurred", http_res.status_code, http_res_text, http_res
246
- )
233
+ raise errors.APIError("API error occurred", http_res, http_res_text)
247
234
  if utils.match_response(http_res, "5XX", "*"):
248
235
  http_res_text = await utils.stream_to_text_async(http_res)
249
- raise models.APIError(
250
- "API error occurred", http_res.status_code, http_res_text, http_res
251
- )
236
+ raise errors.APIError("API error occurred", http_res, http_res_text)
252
237
 
253
- content_type = http_res.headers.get("Content-Type")
254
- http_res_text = await utils.stream_to_text_async(http_res)
255
- raise models.APIError(
256
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
257
- http_res.status_code,
258
- http_res_text,
259
- http_res,
260
- )
238
+ raise errors.APIError("Unexpected response received", http_res)
261
239
 
262
240
  def create(
263
241
  self,
@@ -336,31 +314,20 @@ class Batches(BaseSDK):
336
314
 
337
315
  response_data: Any = None
338
316
  if utils.match_response(http_res, "200", "application/json"):
339
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
317
+ return utils.unmarshal_json_response(models.CommunicationBatch, http_res)
340
318
  if utils.match_response(http_res, "422", "application/json"):
341
- response_data = utils.unmarshal_json(
342
- http_res.text, models.HTTPValidationErrorData
319
+ response_data = utils.unmarshal_json_response(
320
+ errors.HTTPValidationErrorData, http_res
343
321
  )
344
- raise models.HTTPValidationError(data=response_data)
322
+ raise errors.HTTPValidationError(response_data, http_res)
345
323
  if utils.match_response(http_res, "4XX", "*"):
346
324
  http_res_text = utils.stream_to_text(http_res)
347
- raise models.APIError(
348
- "API error occurred", http_res.status_code, http_res_text, http_res
349
- )
325
+ raise errors.APIError("API error occurred", http_res, http_res_text)
350
326
  if utils.match_response(http_res, "5XX", "*"):
351
327
  http_res_text = utils.stream_to_text(http_res)
352
- raise models.APIError(
353
- "API error occurred", http_res.status_code, http_res_text, http_res
354
- )
328
+ raise errors.APIError("API error occurred", http_res, http_res_text)
355
329
 
356
- content_type = http_res.headers.get("Content-Type")
357
- http_res_text = utils.stream_to_text(http_res)
358
- raise models.APIError(
359
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
360
- http_res.status_code,
361
- http_res_text,
362
- http_res,
363
- )
330
+ raise errors.APIError("Unexpected response received", http_res)
364
331
 
365
332
  async def create_async(
366
333
  self,
@@ -439,31 +406,20 @@ class Batches(BaseSDK):
439
406
 
440
407
  response_data: Any = None
441
408
  if utils.match_response(http_res, "200", "application/json"):
442
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
409
+ return utils.unmarshal_json_response(models.CommunicationBatch, http_res)
443
410
  if utils.match_response(http_res, "422", "application/json"):
444
- response_data = utils.unmarshal_json(
445
- http_res.text, models.HTTPValidationErrorData
411
+ response_data = utils.unmarshal_json_response(
412
+ errors.HTTPValidationErrorData, http_res
446
413
  )
447
- raise models.HTTPValidationError(data=response_data)
414
+ raise errors.HTTPValidationError(response_data, http_res)
448
415
  if utils.match_response(http_res, "4XX", "*"):
449
416
  http_res_text = await utils.stream_to_text_async(http_res)
450
- raise models.APIError(
451
- "API error occurred", http_res.status_code, http_res_text, http_res
452
- )
417
+ raise errors.APIError("API error occurred", http_res, http_res_text)
453
418
  if utils.match_response(http_res, "5XX", "*"):
454
419
  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
- )
420
+ raise errors.APIError("API error occurred", http_res, http_res_text)
458
421
 
459
- content_type = http_res.headers.get("Content-Type")
460
- http_res_text = await utils.stream_to_text_async(http_res)
461
- raise models.APIError(
462
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
463
- http_res.status_code,
464
- http_res_text,
465
- http_res,
466
- )
422
+ raise errors.APIError("Unexpected response received", http_res)
467
423
 
468
424
  def get_by_id(
469
425
  self,
@@ -537,31 +493,20 @@ class Batches(BaseSDK):
537
493
 
538
494
  response_data: Any = None
539
495
  if utils.match_response(http_res, "200", "application/json"):
540
- return utils.unmarshal_json(http_res.text, models.BatchDetails)
496
+ return utils.unmarshal_json_response(models.BatchDetails, http_res)
541
497
  if utils.match_response(http_res, "422", "application/json"):
542
- response_data = utils.unmarshal_json(
543
- http_res.text, models.HTTPValidationErrorData
498
+ response_data = utils.unmarshal_json_response(
499
+ errors.HTTPValidationErrorData, http_res
544
500
  )
545
- raise models.HTTPValidationError(data=response_data)
501
+ raise errors.HTTPValidationError(response_data, http_res)
546
502
  if utils.match_response(http_res, "4XX", "*"):
547
503
  http_res_text = utils.stream_to_text(http_res)
548
- raise models.APIError(
549
- "API error occurred", http_res.status_code, http_res_text, http_res
550
- )
504
+ raise errors.APIError("API error occurred", http_res, http_res_text)
551
505
  if utils.match_response(http_res, "5XX", "*"):
552
506
  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
- )
507
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
508
 
557
- content_type = http_res.headers.get("Content-Type")
558
- http_res_text = utils.stream_to_text(http_res)
559
- raise models.APIError(
560
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
561
- http_res.status_code,
562
- http_res_text,
563
- http_res,
564
- )
509
+ raise errors.APIError("Unexpected response received", http_res)
565
510
 
566
511
  async def get_by_id_async(
567
512
  self,
@@ -635,31 +580,20 @@ class Batches(BaseSDK):
635
580
 
636
581
  response_data: Any = None
637
582
  if utils.match_response(http_res, "200", "application/json"):
638
- return utils.unmarshal_json(http_res.text, models.BatchDetails)
583
+ return utils.unmarshal_json_response(models.BatchDetails, http_res)
639
584
  if utils.match_response(http_res, "422", "application/json"):
640
- response_data = utils.unmarshal_json(
641
- http_res.text, models.HTTPValidationErrorData
585
+ response_data = utils.unmarshal_json_response(
586
+ errors.HTTPValidationErrorData, http_res
642
587
  )
643
- raise models.HTTPValidationError(data=response_data)
588
+ raise errors.HTTPValidationError(response_data, http_res)
644
589
  if utils.match_response(http_res, "4XX", "*"):
645
590
  http_res_text = await utils.stream_to_text_async(http_res)
646
- raise models.APIError(
647
- "API error occurred", http_res.status_code, http_res_text, http_res
648
- )
591
+ raise errors.APIError("API error occurred", http_res, http_res_text)
649
592
  if utils.match_response(http_res, "5XX", "*"):
650
593
  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
- )
594
+ raise errors.APIError("API error occurred", http_res, http_res_text)
654
595
 
655
- content_type = http_res.headers.get("Content-Type")
656
- http_res_text = await utils.stream_to_text_async(http_res)
657
- raise models.APIError(
658
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
659
- http_res.status_code,
660
- http_res_text,
661
- http_res,
662
- )
596
+ raise errors.APIError("Unexpected response received", http_res)
663
597
 
664
598
  def update(
665
599
  self,
@@ -747,31 +681,20 @@ class Batches(BaseSDK):
747
681
 
748
682
  response_data: Any = None
749
683
  if utils.match_response(http_res, "200", "application/json"):
750
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
684
+ return utils.unmarshal_json_response(models.CommunicationBatch, http_res)
751
685
  if utils.match_response(http_res, "422", "application/json"):
752
- response_data = utils.unmarshal_json(
753
- http_res.text, models.HTTPValidationErrorData
686
+ response_data = utils.unmarshal_json_response(
687
+ errors.HTTPValidationErrorData, http_res
754
688
  )
755
- raise models.HTTPValidationError(data=response_data)
689
+ raise errors.HTTPValidationError(response_data, http_res)
756
690
  if utils.match_response(http_res, "4XX", "*"):
757
691
  http_res_text = utils.stream_to_text(http_res)
758
- raise models.APIError(
759
- "API error occurred", http_res.status_code, http_res_text, http_res
760
- )
692
+ raise errors.APIError("API error occurred", http_res, http_res_text)
761
693
  if utils.match_response(http_res, "5XX", "*"):
762
694
  http_res_text = utils.stream_to_text(http_res)
763
- raise models.APIError(
764
- "API error occurred", http_res.status_code, http_res_text, http_res
765
- )
695
+ raise errors.APIError("API error occurred", http_res, http_res_text)
766
696
 
767
- content_type = http_res.headers.get("Content-Type")
768
- http_res_text = utils.stream_to_text(http_res)
769
- raise models.APIError(
770
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
771
- http_res.status_code,
772
- http_res_text,
773
- http_res,
774
- )
697
+ raise errors.APIError("Unexpected response received", http_res)
775
698
 
776
699
  async def update_async(
777
700
  self,
@@ -859,31 +782,20 @@ class Batches(BaseSDK):
859
782
 
860
783
  response_data: Any = None
861
784
  if utils.match_response(http_res, "200", "application/json"):
862
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
785
+ return utils.unmarshal_json_response(models.CommunicationBatch, http_res)
863
786
  if utils.match_response(http_res, "422", "application/json"):
864
- response_data = utils.unmarshal_json(
865
- http_res.text, models.HTTPValidationErrorData
787
+ response_data = utils.unmarshal_json_response(
788
+ errors.HTTPValidationErrorData, http_res
866
789
  )
867
- raise models.HTTPValidationError(data=response_data)
790
+ raise errors.HTTPValidationError(response_data, http_res)
868
791
  if utils.match_response(http_res, "4XX", "*"):
869
792
  http_res_text = await utils.stream_to_text_async(http_res)
870
- raise models.APIError(
871
- "API error occurred", http_res.status_code, http_res_text, http_res
872
- )
793
+ raise errors.APIError("API error occurred", http_res, http_res_text)
873
794
  if utils.match_response(http_res, "5XX", "*"):
874
795
  http_res_text = await utils.stream_to_text_async(http_res)
875
- raise models.APIError(
876
- "API error occurred", http_res.status_code, http_res_text, http_res
877
- )
796
+ raise errors.APIError("API error occurred", http_res, http_res_text)
878
797
 
879
- content_type = http_res.headers.get("Content-Type")
880
- http_res_text = await utils.stream_to_text_async(http_res)
881
- raise models.APIError(
882
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
883
- http_res.status_code,
884
- http_res_text,
885
- http_res,
886
- )
798
+ raise errors.APIError("Unexpected response received", http_res)
887
799
 
888
800
  def delete(
889
801
  self,
@@ -971,31 +883,20 @@ class Batches(BaseSDK):
971
883
 
972
884
  response_data: Any = None
973
885
  if utils.match_response(http_res, "200", "application/json"):
974
- return utils.unmarshal_json(http_res.text, Any)
886
+ return utils.unmarshal_json_response(Any, http_res)
975
887
  if utils.match_response(http_res, "422", "application/json"):
976
- response_data = utils.unmarshal_json(
977
- http_res.text, models.HTTPValidationErrorData
888
+ response_data = utils.unmarshal_json_response(
889
+ errors.HTTPValidationErrorData, http_res
978
890
  )
979
- raise models.HTTPValidationError(data=response_data)
891
+ raise errors.HTTPValidationError(response_data, http_res)
980
892
  if utils.match_response(http_res, "4XX", "*"):
981
893
  http_res_text = utils.stream_to_text(http_res)
982
- raise models.APIError(
983
- "API error occurred", http_res.status_code, http_res_text, http_res
984
- )
894
+ raise errors.APIError("API error occurred", http_res, http_res_text)
985
895
  if utils.match_response(http_res, "5XX", "*"):
986
896
  http_res_text = utils.stream_to_text(http_res)
987
- raise models.APIError(
988
- "API error occurred", http_res.status_code, http_res_text, http_res
989
- )
897
+ raise errors.APIError("API error occurred", http_res, http_res_text)
990
898
 
991
- content_type = http_res.headers.get("Content-Type")
992
- http_res_text = utils.stream_to_text(http_res)
993
- raise models.APIError(
994
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
995
- http_res.status_code,
996
- http_res_text,
997
- http_res,
998
- )
899
+ raise errors.APIError("Unexpected response received", http_res)
999
900
 
1000
901
  async def delete_async(
1001
902
  self,
@@ -1083,31 +984,20 @@ class Batches(BaseSDK):
1083
984
 
1084
985
  response_data: Any = None
1085
986
  if utils.match_response(http_res, "200", "application/json"):
1086
- return utils.unmarshal_json(http_res.text, Any)
987
+ return utils.unmarshal_json_response(Any, http_res)
1087
988
  if utils.match_response(http_res, "422", "application/json"):
1088
- response_data = utils.unmarshal_json(
1089
- http_res.text, models.HTTPValidationErrorData
989
+ response_data = utils.unmarshal_json_response(
990
+ errors.HTTPValidationErrorData, http_res
1090
991
  )
1091
- raise models.HTTPValidationError(data=response_data)
992
+ raise errors.HTTPValidationError(response_data, http_res)
1092
993
  if utils.match_response(http_res, "4XX", "*"):
1093
994
  http_res_text = await utils.stream_to_text_async(http_res)
1094
- raise models.APIError(
1095
- "API error occurred", http_res.status_code, http_res_text, http_res
1096
- )
995
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1097
996
  if utils.match_response(http_res, "5XX", "*"):
1098
997
  http_res_text = await utils.stream_to_text_async(http_res)
1099
- raise models.APIError(
1100
- "API error occurred", http_res.status_code, http_res_text, http_res
1101
- )
998
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1102
999
 
1103
- content_type = http_res.headers.get("Content-Type")
1104
- http_res_text = await utils.stream_to_text_async(http_res)
1105
- raise models.APIError(
1106
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1107
- http_res.status_code,
1108
- http_res_text,
1109
- http_res,
1110
- )
1000
+ raise errors.APIError("Unexpected response received", http_res)
1111
1001
 
1112
1002
  def upload(
1113
1003
  self,
@@ -1197,31 +1087,20 @@ class Batches(BaseSDK):
1197
1087
 
1198
1088
  response_data: Any = None
1199
1089
  if utils.match_response(http_res, "200", "application/json"):
1200
- return utils.unmarshal_json(http_res.text, Any)
1090
+ return utils.unmarshal_json_response(Any, http_res)
1201
1091
  if utils.match_response(http_res, "422", "application/json"):
1202
- response_data = utils.unmarshal_json(
1203
- http_res.text, models.HTTPValidationErrorData
1092
+ response_data = utils.unmarshal_json_response(
1093
+ errors.HTTPValidationErrorData, http_res
1204
1094
  )
1205
- raise models.HTTPValidationError(data=response_data)
1095
+ raise errors.HTTPValidationError(response_data, http_res)
1206
1096
  if utils.match_response(http_res, "4XX", "*"):
1207
1097
  http_res_text = utils.stream_to_text(http_res)
1208
- raise models.APIError(
1209
- "API error occurred", http_res.status_code, http_res_text, http_res
1210
- )
1098
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1211
1099
  if utils.match_response(http_res, "5XX", "*"):
1212
1100
  http_res_text = utils.stream_to_text(http_res)
1213
- raise models.APIError(
1214
- "API error occurred", http_res.status_code, http_res_text, http_res
1215
- )
1101
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1216
1102
 
1217
- content_type = http_res.headers.get("Content-Type")
1218
- http_res_text = utils.stream_to_text(http_res)
1219
- raise models.APIError(
1220
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1221
- http_res.status_code,
1222
- http_res_text,
1223
- http_res,
1224
- )
1103
+ raise errors.APIError("Unexpected response received", http_res)
1225
1104
 
1226
1105
  async def upload_async(
1227
1106
  self,
@@ -1311,31 +1190,20 @@ class Batches(BaseSDK):
1311
1190
 
1312
1191
  response_data: Any = None
1313
1192
  if utils.match_response(http_res, "200", "application/json"):
1314
- return utils.unmarshal_json(http_res.text, Any)
1193
+ return utils.unmarshal_json_response(Any, http_res)
1315
1194
  if utils.match_response(http_res, "422", "application/json"):
1316
- response_data = utils.unmarshal_json(
1317
- http_res.text, models.HTTPValidationErrorData
1195
+ response_data = utils.unmarshal_json_response(
1196
+ errors.HTTPValidationErrorData, http_res
1318
1197
  )
1319
- raise models.HTTPValidationError(data=response_data)
1198
+ raise errors.HTTPValidationError(response_data, http_res)
1320
1199
  if utils.match_response(http_res, "4XX", "*"):
1321
1200
  http_res_text = await utils.stream_to_text_async(http_res)
1322
- raise models.APIError(
1323
- "API error occurred", http_res.status_code, http_res_text, http_res
1324
- )
1201
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1325
1202
  if utils.match_response(http_res, "5XX", "*"):
1326
1203
  http_res_text = await utils.stream_to_text_async(http_res)
1327
- raise models.APIError(
1328
- "API error occurred", http_res.status_code, http_res_text, http_res
1329
- )
1204
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1330
1205
 
1331
- content_type = http_res.headers.get("Content-Type")
1332
- http_res_text = await utils.stream_to_text_async(http_res)
1333
- raise models.APIError(
1334
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1335
- http_res.status_code,
1336
- http_res_text,
1337
- http_res,
1338
- )
1206
+ raise errors.APIError("Unexpected response received", http_res)
1339
1207
 
1340
1208
  def results(
1341
1209
  self,
@@ -1418,33 +1286,22 @@ class Batches(BaseSDK):
1418
1286
 
1419
1287
  response_data: Any = None
1420
1288
  if utils.match_response(http_res, "200", "application/json"):
1421
- return utils.unmarshal_json(
1422
- http_res.text, List[models.CommunicationRequestResult]
1289
+ return utils.unmarshal_json_response(
1290
+ List[models.CommunicationRequestResult], http_res
1423
1291
  )
1424
1292
  if utils.match_response(http_res, "422", "application/json"):
1425
- response_data = utils.unmarshal_json(
1426
- http_res.text, models.HTTPValidationErrorData
1293
+ response_data = utils.unmarshal_json_response(
1294
+ errors.HTTPValidationErrorData, http_res
1427
1295
  )
1428
- raise models.HTTPValidationError(data=response_data)
1296
+ raise errors.HTTPValidationError(response_data, http_res)
1429
1297
  if utils.match_response(http_res, "4XX", "*"):
1430
1298
  http_res_text = utils.stream_to_text(http_res)
1431
- raise models.APIError(
1432
- "API error occurred", http_res.status_code, http_res_text, http_res
1433
- )
1299
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1434
1300
  if utils.match_response(http_res, "5XX", "*"):
1435
1301
  http_res_text = utils.stream_to_text(http_res)
1436
- raise models.APIError(
1437
- "API error occurred", http_res.status_code, http_res_text, http_res
1438
- )
1302
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1439
1303
 
1440
- content_type = http_res.headers.get("Content-Type")
1441
- http_res_text = utils.stream_to_text(http_res)
1442
- raise models.APIError(
1443
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1444
- http_res.status_code,
1445
- http_res_text,
1446
- http_res,
1447
- )
1304
+ raise errors.APIError("Unexpected response received", http_res)
1448
1305
 
1449
1306
  async def results_async(
1450
1307
  self,
@@ -1527,33 +1384,22 @@ class Batches(BaseSDK):
1527
1384
 
1528
1385
  response_data: Any = None
1529
1386
  if utils.match_response(http_res, "200", "application/json"):
1530
- return utils.unmarshal_json(
1531
- http_res.text, List[models.CommunicationRequestResult]
1387
+ return utils.unmarshal_json_response(
1388
+ List[models.CommunicationRequestResult], http_res
1532
1389
  )
1533
1390
  if utils.match_response(http_res, "422", "application/json"):
1534
- response_data = utils.unmarshal_json(
1535
- http_res.text, models.HTTPValidationErrorData
1391
+ response_data = utils.unmarshal_json_response(
1392
+ errors.HTTPValidationErrorData, http_res
1536
1393
  )
1537
- raise models.HTTPValidationError(data=response_data)
1394
+ raise errors.HTTPValidationError(response_data, http_res)
1538
1395
  if utils.match_response(http_res, "4XX", "*"):
1539
1396
  http_res_text = await utils.stream_to_text_async(http_res)
1540
- raise models.APIError(
1541
- "API error occurred", http_res.status_code, http_res_text, http_res
1542
- )
1397
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1543
1398
  if utils.match_response(http_res, "5XX", "*"):
1544
1399
  http_res_text = await utils.stream_to_text_async(http_res)
1545
- raise models.APIError(
1546
- "API error occurred", http_res.status_code, http_res_text, http_res
1547
- )
1400
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1548
1401
 
1549
- content_type = http_res.headers.get("Content-Type")
1550
- http_res_text = await utils.stream_to_text_async(http_res)
1551
- raise models.APIError(
1552
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1553
- http_res.status_code,
1554
- http_res_text,
1555
- http_res,
1556
- )
1402
+ raise errors.APIError("Unexpected response received", http_res)
1557
1403
 
1558
1404
  def add(
1559
1405
  self,
@@ -1641,31 +1487,20 @@ class Batches(BaseSDK):
1641
1487
 
1642
1488
  response_data: Any = None
1643
1489
  if utils.match_response(http_res, "200", "application/json"):
1644
- return utils.unmarshal_json(http_res.text, Any)
1490
+ return utils.unmarshal_json_response(Any, http_res)
1645
1491
  if utils.match_response(http_res, "422", "application/json"):
1646
- response_data = utils.unmarshal_json(
1647
- http_res.text, models.HTTPValidationErrorData
1492
+ response_data = utils.unmarshal_json_response(
1493
+ errors.HTTPValidationErrorData, http_res
1648
1494
  )
1649
- raise models.HTTPValidationError(data=response_data)
1495
+ raise errors.HTTPValidationError(response_data, http_res)
1650
1496
  if utils.match_response(http_res, "4XX", "*"):
1651
1497
  http_res_text = utils.stream_to_text(http_res)
1652
- raise models.APIError(
1653
- "API error occurred", http_res.status_code, http_res_text, http_res
1654
- )
1498
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1655
1499
  if utils.match_response(http_res, "5XX", "*"):
1656
1500
  http_res_text = utils.stream_to_text(http_res)
1657
- raise models.APIError(
1658
- "API error occurred", http_res.status_code, http_res_text, http_res
1659
- )
1501
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1660
1502
 
1661
- content_type = http_res.headers.get("Content-Type")
1662
- http_res_text = utils.stream_to_text(http_res)
1663
- raise models.APIError(
1664
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1665
- http_res.status_code,
1666
- http_res_text,
1667
- http_res,
1668
- )
1503
+ raise errors.APIError("Unexpected response received", http_res)
1669
1504
 
1670
1505
  async def add_async(
1671
1506
  self,
@@ -1753,31 +1588,20 @@ class Batches(BaseSDK):
1753
1588
 
1754
1589
  response_data: Any = None
1755
1590
  if utils.match_response(http_res, "200", "application/json"):
1756
- return utils.unmarshal_json(http_res.text, Any)
1591
+ return utils.unmarshal_json_response(Any, http_res)
1757
1592
  if utils.match_response(http_res, "422", "application/json"):
1758
- response_data = utils.unmarshal_json(
1759
- http_res.text, models.HTTPValidationErrorData
1593
+ response_data = utils.unmarshal_json_response(
1594
+ errors.HTTPValidationErrorData, http_res
1760
1595
  )
1761
- raise models.HTTPValidationError(data=response_data)
1596
+ raise errors.HTTPValidationError(response_data, http_res)
1762
1597
  if utils.match_response(http_res, "4XX", "*"):
1763
1598
  http_res_text = await utils.stream_to_text_async(http_res)
1764
- raise models.APIError(
1765
- "API error occurred", http_res.status_code, http_res_text, http_res
1766
- )
1599
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1767
1600
  if utils.match_response(http_res, "5XX", "*"):
1768
1601
  http_res_text = await utils.stream_to_text_async(http_res)
1769
- raise models.APIError(
1770
- "API error occurred", http_res.status_code, http_res_text, http_res
1771
- )
1602
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1772
1603
 
1773
- content_type = http_res.headers.get("Content-Type")
1774
- http_res_text = await utils.stream_to_text_async(http_res)
1775
- raise models.APIError(
1776
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1777
- http_res.status_code,
1778
- http_res_text,
1779
- http_res,
1780
- )
1604
+ raise errors.APIError("Unexpected response received", http_res)
1781
1605
 
1782
1606
  def remove(
1783
1607
  self,
@@ -1857,31 +1681,20 @@ class Batches(BaseSDK):
1857
1681
 
1858
1682
  response_data: Any = None
1859
1683
  if utils.match_response(http_res, "200", "application/json"):
1860
- return utils.unmarshal_json(http_res.text, Any)
1684
+ return utils.unmarshal_json_response(Any, http_res)
1861
1685
  if utils.match_response(http_res, "422", "application/json"):
1862
- response_data = utils.unmarshal_json(
1863
- http_res.text, models.HTTPValidationErrorData
1686
+ response_data = utils.unmarshal_json_response(
1687
+ errors.HTTPValidationErrorData, http_res
1864
1688
  )
1865
- raise models.HTTPValidationError(data=response_data)
1689
+ raise errors.HTTPValidationError(response_data, http_res)
1866
1690
  if utils.match_response(http_res, "4XX", "*"):
1867
1691
  http_res_text = utils.stream_to_text(http_res)
1868
- raise models.APIError(
1869
- "API error occurred", http_res.status_code, http_res_text, http_res
1870
- )
1692
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1871
1693
  if utils.match_response(http_res, "5XX", "*"):
1872
1694
  http_res_text = utils.stream_to_text(http_res)
1873
- raise models.APIError(
1874
- "API error occurred", http_res.status_code, http_res_text, http_res
1875
- )
1695
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1876
1696
 
1877
- content_type = http_res.headers.get("Content-Type")
1878
- http_res_text = utils.stream_to_text(http_res)
1879
- raise models.APIError(
1880
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1881
- http_res.status_code,
1882
- http_res_text,
1883
- http_res,
1884
- )
1697
+ raise errors.APIError("Unexpected response received", http_res)
1885
1698
 
1886
1699
  async def remove_async(
1887
1700
  self,
@@ -1961,28 +1774,17 @@ class Batches(BaseSDK):
1961
1774
 
1962
1775
  response_data: Any = None
1963
1776
  if utils.match_response(http_res, "200", "application/json"):
1964
- return utils.unmarshal_json(http_res.text, Any)
1777
+ return utils.unmarshal_json_response(Any, http_res)
1965
1778
  if utils.match_response(http_res, "422", "application/json"):
1966
- response_data = utils.unmarshal_json(
1967
- http_res.text, models.HTTPValidationErrorData
1779
+ response_data = utils.unmarshal_json_response(
1780
+ errors.HTTPValidationErrorData, http_res
1968
1781
  )
1969
- raise models.HTTPValidationError(data=response_data)
1782
+ raise errors.HTTPValidationError(response_data, http_res)
1970
1783
  if utils.match_response(http_res, "4XX", "*"):
1971
1784
  http_res_text = await utils.stream_to_text_async(http_res)
1972
- raise models.APIError(
1973
- "API error occurred", http_res.status_code, http_res_text, http_res
1974
- )
1785
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1975
1786
  if utils.match_response(http_res, "5XX", "*"):
1976
1787
  http_res_text = await utils.stream_to_text_async(http_res)
1977
- raise models.APIError(
1978
- "API error occurred", http_res.status_code, http_res_text, http_res
1979
- )
1788
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1980
1789
 
1981
- content_type = http_res.headers.get("Content-Type")
1982
- http_res_text = await utils.stream_to_text_async(http_res)
1983
- raise models.APIError(
1984
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1985
- http_res.status_code,
1986
- http_res_text,
1987
- http_res,
1988
- )
1790
+ raise errors.APIError("Unexpected response received", http_res)