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
syllable_sdk/batches.py CHANGED
@@ -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
 
@@ -107,33 +108,22 @@ class Batches(BaseSDK):
107
108
 
108
109
  response_data: Any = None
109
110
  if utils.match_response(http_res, "200", "application/json"):
110
- return utils.unmarshal_json(
111
- http_res.text, models.ListResponseCommunicationBatch
111
+ return unmarshal_json_response(
112
+ models.ListResponseCommunicationBatch, http_res
112
113
  )
113
114
  if utils.match_response(http_res, "422", "application/json"):
114
- response_data = utils.unmarshal_json(
115
- http_res.text, models.HTTPValidationErrorData
115
+ response_data = unmarshal_json_response(
116
+ errors.HTTPValidationErrorData, http_res
116
117
  )
117
- raise models.HTTPValidationError(data=response_data)
118
+ raise errors.HTTPValidationError(response_data, http_res)
118
119
  if utils.match_response(http_res, "4XX", "*"):
119
120
  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
- )
121
+ raise errors.APIError("API error occurred", http_res, http_res_text)
123
122
  if utils.match_response(http_res, "5XX", "*"):
124
123
  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
- )
124
+ raise errors.APIError("API error occurred", http_res, http_res_text)
128
125
 
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
- )
126
+ raise errors.APIError("Unexpected response received", http_res)
137
127
 
138
128
  async def list_async(
139
129
  self,
@@ -231,33 +221,22 @@ class Batches(BaseSDK):
231
221
 
232
222
  response_data: Any = None
233
223
  if utils.match_response(http_res, "200", "application/json"):
234
- return utils.unmarshal_json(
235
- http_res.text, models.ListResponseCommunicationBatch
224
+ return unmarshal_json_response(
225
+ models.ListResponseCommunicationBatch, http_res
236
226
  )
237
227
  if utils.match_response(http_res, "422", "application/json"):
238
- response_data = utils.unmarshal_json(
239
- http_res.text, models.HTTPValidationErrorData
228
+ response_data = unmarshal_json_response(
229
+ errors.HTTPValidationErrorData, http_res
240
230
  )
241
- raise models.HTTPValidationError(data=response_data)
231
+ raise errors.HTTPValidationError(response_data, http_res)
242
232
  if utils.match_response(http_res, "4XX", "*"):
243
233
  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
- )
234
+ raise errors.APIError("API error occurred", http_res, http_res_text)
247
235
  if utils.match_response(http_res, "5XX", "*"):
248
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
252
238
 
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
- )
239
+ raise errors.APIError("Unexpected response received", http_res)
261
240
 
262
241
  def create(
263
242
  self,
@@ -336,31 +315,20 @@ class Batches(BaseSDK):
336
315
 
337
316
  response_data: Any = None
338
317
  if utils.match_response(http_res, "200", "application/json"):
339
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
318
+ return unmarshal_json_response(models.CommunicationBatch, http_res)
340
319
  if utils.match_response(http_res, "422", "application/json"):
341
- response_data = utils.unmarshal_json(
342
- http_res.text, models.HTTPValidationErrorData
320
+ response_data = unmarshal_json_response(
321
+ errors.HTTPValidationErrorData, http_res
343
322
  )
344
- raise models.HTTPValidationError(data=response_data)
323
+ raise errors.HTTPValidationError(response_data, http_res)
345
324
  if utils.match_response(http_res, "4XX", "*"):
346
325
  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
- )
326
+ raise errors.APIError("API error occurred", http_res, http_res_text)
350
327
  if utils.match_response(http_res, "5XX", "*"):
351
328
  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
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
355
330
 
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
- )
331
+ raise errors.APIError("Unexpected response received", http_res)
364
332
 
365
333
  async def create_async(
366
334
  self,
@@ -439,31 +407,20 @@ class Batches(BaseSDK):
439
407
 
440
408
  response_data: Any = None
441
409
  if utils.match_response(http_res, "200", "application/json"):
442
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
410
+ return unmarshal_json_response(models.CommunicationBatch, http_res)
443
411
  if utils.match_response(http_res, "422", "application/json"):
444
- response_data = utils.unmarshal_json(
445
- http_res.text, models.HTTPValidationErrorData
412
+ response_data = unmarshal_json_response(
413
+ errors.HTTPValidationErrorData, http_res
446
414
  )
447
- raise models.HTTPValidationError(data=response_data)
415
+ raise errors.HTTPValidationError(response_data, http_res)
448
416
  if utils.match_response(http_res, "4XX", "*"):
449
417
  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
- )
418
+ raise errors.APIError("API error occurred", http_res, http_res_text)
453
419
  if utils.match_response(http_res, "5XX", "*"):
454
420
  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
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
458
422
 
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
- )
423
+ raise errors.APIError("Unexpected response received", http_res)
467
424
 
468
425
  def get_by_id(
469
426
  self,
@@ -537,31 +494,20 @@ class Batches(BaseSDK):
537
494
 
538
495
  response_data: Any = None
539
496
  if utils.match_response(http_res, "200", "application/json"):
540
- return utils.unmarshal_json(http_res.text, models.BatchDetails)
497
+ return unmarshal_json_response(models.BatchDetails, http_res)
541
498
  if utils.match_response(http_res, "422", "application/json"):
542
- response_data = utils.unmarshal_json(
543
- http_res.text, models.HTTPValidationErrorData
499
+ response_data = unmarshal_json_response(
500
+ errors.HTTPValidationErrorData, http_res
544
501
  )
545
- raise models.HTTPValidationError(data=response_data)
502
+ raise errors.HTTPValidationError(response_data, http_res)
546
503
  if utils.match_response(http_res, "4XX", "*"):
547
504
  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
- )
505
+ raise errors.APIError("API error occurred", http_res, http_res_text)
551
506
  if utils.match_response(http_res, "5XX", "*"):
552
507
  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
- )
508
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
509
 
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
- )
510
+ raise errors.APIError("Unexpected response received", http_res)
565
511
 
566
512
  async def get_by_id_async(
567
513
  self,
@@ -635,31 +581,20 @@ class Batches(BaseSDK):
635
581
 
636
582
  response_data: Any = None
637
583
  if utils.match_response(http_res, "200", "application/json"):
638
- return utils.unmarshal_json(http_res.text, models.BatchDetails)
584
+ return unmarshal_json_response(models.BatchDetails, http_res)
639
585
  if utils.match_response(http_res, "422", "application/json"):
640
- response_data = utils.unmarshal_json(
641
- http_res.text, models.HTTPValidationErrorData
586
+ response_data = unmarshal_json_response(
587
+ errors.HTTPValidationErrorData, http_res
642
588
  )
643
- raise models.HTTPValidationError(data=response_data)
589
+ raise errors.HTTPValidationError(response_data, http_res)
644
590
  if utils.match_response(http_res, "4XX", "*"):
645
591
  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
- )
592
+ raise errors.APIError("API error occurred", http_res, http_res_text)
649
593
  if utils.match_response(http_res, "5XX", "*"):
650
594
  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
- )
595
+ raise errors.APIError("API error occurred", http_res, http_res_text)
654
596
 
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
- )
597
+ raise errors.APIError("Unexpected response received", http_res)
663
598
 
664
599
  def update(
665
600
  self,
@@ -747,31 +682,20 @@ class Batches(BaseSDK):
747
682
 
748
683
  response_data: Any = None
749
684
  if utils.match_response(http_res, "200", "application/json"):
750
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
685
+ return unmarshal_json_response(models.CommunicationBatch, http_res)
751
686
  if utils.match_response(http_res, "422", "application/json"):
752
- response_data = utils.unmarshal_json(
753
- http_res.text, models.HTTPValidationErrorData
687
+ response_data = unmarshal_json_response(
688
+ errors.HTTPValidationErrorData, http_res
754
689
  )
755
- raise models.HTTPValidationError(data=response_data)
690
+ raise errors.HTTPValidationError(response_data, http_res)
756
691
  if utils.match_response(http_res, "4XX", "*"):
757
692
  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
- )
693
+ raise errors.APIError("API error occurred", http_res, http_res_text)
761
694
  if utils.match_response(http_res, "5XX", "*"):
762
695
  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
- )
696
+ raise errors.APIError("API error occurred", http_res, http_res_text)
766
697
 
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
- )
698
+ raise errors.APIError("Unexpected response received", http_res)
775
699
 
776
700
  async def update_async(
777
701
  self,
@@ -859,31 +783,20 @@ class Batches(BaseSDK):
859
783
 
860
784
  response_data: Any = None
861
785
  if utils.match_response(http_res, "200", "application/json"):
862
- return utils.unmarshal_json(http_res.text, models.CommunicationBatch)
786
+ return unmarshal_json_response(models.CommunicationBatch, http_res)
863
787
  if utils.match_response(http_res, "422", "application/json"):
864
- response_data = utils.unmarshal_json(
865
- http_res.text, models.HTTPValidationErrorData
788
+ response_data = unmarshal_json_response(
789
+ errors.HTTPValidationErrorData, http_res
866
790
  )
867
- raise models.HTTPValidationError(data=response_data)
791
+ raise errors.HTTPValidationError(response_data, http_res)
868
792
  if utils.match_response(http_res, "4XX", "*"):
869
793
  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
- )
794
+ raise errors.APIError("API error occurred", http_res, http_res_text)
873
795
  if utils.match_response(http_res, "5XX", "*"):
874
796
  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
- )
797
+ raise errors.APIError("API error occurred", http_res, http_res_text)
878
798
 
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
- )
799
+ raise errors.APIError("Unexpected response received", http_res)
887
800
 
888
801
  def delete(
889
802
  self,
@@ -971,31 +884,20 @@ class Batches(BaseSDK):
971
884
 
972
885
  response_data: Any = None
973
886
  if utils.match_response(http_res, "200", "application/json"):
974
- return utils.unmarshal_json(http_res.text, Any)
887
+ return unmarshal_json_response(Any, http_res)
975
888
  if utils.match_response(http_res, "422", "application/json"):
976
- response_data = utils.unmarshal_json(
977
- http_res.text, models.HTTPValidationErrorData
889
+ response_data = unmarshal_json_response(
890
+ errors.HTTPValidationErrorData, http_res
978
891
  )
979
- raise models.HTTPValidationError(data=response_data)
892
+ raise errors.HTTPValidationError(response_data, http_res)
980
893
  if utils.match_response(http_res, "4XX", "*"):
981
894
  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
- )
895
+ raise errors.APIError("API error occurred", http_res, http_res_text)
985
896
  if utils.match_response(http_res, "5XX", "*"):
986
897
  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
- )
898
+ raise errors.APIError("API error occurred", http_res, http_res_text)
990
899
 
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
- )
900
+ raise errors.APIError("Unexpected response received", http_res)
999
901
 
1000
902
  async def delete_async(
1001
903
  self,
@@ -1083,31 +985,20 @@ class Batches(BaseSDK):
1083
985
 
1084
986
  response_data: Any = None
1085
987
  if utils.match_response(http_res, "200", "application/json"):
1086
- return utils.unmarshal_json(http_res.text, Any)
988
+ return unmarshal_json_response(Any, http_res)
1087
989
  if utils.match_response(http_res, "422", "application/json"):
1088
- response_data = utils.unmarshal_json(
1089
- http_res.text, models.HTTPValidationErrorData
990
+ response_data = unmarshal_json_response(
991
+ errors.HTTPValidationErrorData, http_res
1090
992
  )
1091
- raise models.HTTPValidationError(data=response_data)
993
+ raise errors.HTTPValidationError(response_data, http_res)
1092
994
  if utils.match_response(http_res, "4XX", "*"):
1093
995
  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
- )
996
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1097
997
  if utils.match_response(http_res, "5XX", "*"):
1098
998
  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
- )
999
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1102
1000
 
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
- )
1001
+ raise errors.APIError("Unexpected response received", http_res)
1111
1002
 
1112
1003
  def upload(
1113
1004
  self,
@@ -1197,31 +1088,20 @@ class Batches(BaseSDK):
1197
1088
 
1198
1089
  response_data: Any = None
1199
1090
  if utils.match_response(http_res, "200", "application/json"):
1200
- return utils.unmarshal_json(http_res.text, Any)
1091
+ return unmarshal_json_response(Any, http_res)
1201
1092
  if utils.match_response(http_res, "422", "application/json"):
1202
- response_data = utils.unmarshal_json(
1203
- http_res.text, models.HTTPValidationErrorData
1093
+ response_data = unmarshal_json_response(
1094
+ errors.HTTPValidationErrorData, http_res
1204
1095
  )
1205
- raise models.HTTPValidationError(data=response_data)
1096
+ raise errors.HTTPValidationError(response_data, http_res)
1206
1097
  if utils.match_response(http_res, "4XX", "*"):
1207
1098
  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
- )
1099
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1211
1100
  if utils.match_response(http_res, "5XX", "*"):
1212
1101
  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
- )
1102
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1216
1103
 
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
- )
1104
+ raise errors.APIError("Unexpected response received", http_res)
1225
1105
 
1226
1106
  async def upload_async(
1227
1107
  self,
@@ -1311,31 +1191,20 @@ class Batches(BaseSDK):
1311
1191
 
1312
1192
  response_data: Any = None
1313
1193
  if utils.match_response(http_res, "200", "application/json"):
1314
- return utils.unmarshal_json(http_res.text, Any)
1194
+ return unmarshal_json_response(Any, http_res)
1315
1195
  if utils.match_response(http_res, "422", "application/json"):
1316
- response_data = utils.unmarshal_json(
1317
- http_res.text, models.HTTPValidationErrorData
1196
+ response_data = unmarshal_json_response(
1197
+ errors.HTTPValidationErrorData, http_res
1318
1198
  )
1319
- raise models.HTTPValidationError(data=response_data)
1199
+ raise errors.HTTPValidationError(response_data, http_res)
1320
1200
  if utils.match_response(http_res, "4XX", "*"):
1321
1201
  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
- )
1202
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1325
1203
  if utils.match_response(http_res, "5XX", "*"):
1326
1204
  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
- )
1205
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1330
1206
 
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
- )
1207
+ raise errors.APIError("Unexpected response received", http_res)
1339
1208
 
1340
1209
  def results(
1341
1210
  self,
@@ -1418,33 +1287,22 @@ class Batches(BaseSDK):
1418
1287
 
1419
1288
  response_data: Any = None
1420
1289
  if utils.match_response(http_res, "200", "application/json"):
1421
- return utils.unmarshal_json(
1422
- http_res.text, List[models.CommunicationRequestResult]
1290
+ return unmarshal_json_response(
1291
+ List[models.CommunicationRequestResult], http_res
1423
1292
  )
1424
1293
  if utils.match_response(http_res, "422", "application/json"):
1425
- response_data = utils.unmarshal_json(
1426
- http_res.text, models.HTTPValidationErrorData
1294
+ response_data = unmarshal_json_response(
1295
+ errors.HTTPValidationErrorData, http_res
1427
1296
  )
1428
- raise models.HTTPValidationError(data=response_data)
1297
+ raise errors.HTTPValidationError(response_data, http_res)
1429
1298
  if utils.match_response(http_res, "4XX", "*"):
1430
1299
  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
- )
1300
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1434
1301
  if utils.match_response(http_res, "5XX", "*"):
1435
1302
  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
- )
1303
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1439
1304
 
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
- )
1305
+ raise errors.APIError("Unexpected response received", http_res)
1448
1306
 
1449
1307
  async def results_async(
1450
1308
  self,
@@ -1527,33 +1385,22 @@ class Batches(BaseSDK):
1527
1385
 
1528
1386
  response_data: Any = None
1529
1387
  if utils.match_response(http_res, "200", "application/json"):
1530
- return utils.unmarshal_json(
1531
- http_res.text, List[models.CommunicationRequestResult]
1388
+ return unmarshal_json_response(
1389
+ List[models.CommunicationRequestResult], http_res
1532
1390
  )
1533
1391
  if utils.match_response(http_res, "422", "application/json"):
1534
- response_data = utils.unmarshal_json(
1535
- http_res.text, models.HTTPValidationErrorData
1392
+ response_data = unmarshal_json_response(
1393
+ errors.HTTPValidationErrorData, http_res
1536
1394
  )
1537
- raise models.HTTPValidationError(data=response_data)
1395
+ raise errors.HTTPValidationError(response_data, http_res)
1538
1396
  if utils.match_response(http_res, "4XX", "*"):
1539
1397
  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
- )
1398
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1543
1399
  if utils.match_response(http_res, "5XX", "*"):
1544
1400
  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
- )
1401
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1548
1402
 
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
- )
1403
+ raise errors.APIError("Unexpected response received", http_res)
1557
1404
 
1558
1405
  def add(
1559
1406
  self,
@@ -1641,31 +1488,20 @@ class Batches(BaseSDK):
1641
1488
 
1642
1489
  response_data: Any = None
1643
1490
  if utils.match_response(http_res, "200", "application/json"):
1644
- return utils.unmarshal_json(http_res.text, Any)
1491
+ return unmarshal_json_response(Any, http_res)
1645
1492
  if utils.match_response(http_res, "422", "application/json"):
1646
- response_data = utils.unmarshal_json(
1647
- http_res.text, models.HTTPValidationErrorData
1493
+ response_data = unmarshal_json_response(
1494
+ errors.HTTPValidationErrorData, http_res
1648
1495
  )
1649
- raise models.HTTPValidationError(data=response_data)
1496
+ raise errors.HTTPValidationError(response_data, http_res)
1650
1497
  if utils.match_response(http_res, "4XX", "*"):
1651
1498
  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
- )
1499
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1655
1500
  if utils.match_response(http_res, "5XX", "*"):
1656
1501
  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
- )
1502
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1660
1503
 
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
- )
1504
+ raise errors.APIError("Unexpected response received", http_res)
1669
1505
 
1670
1506
  async def add_async(
1671
1507
  self,
@@ -1753,31 +1589,20 @@ class Batches(BaseSDK):
1753
1589
 
1754
1590
  response_data: Any = None
1755
1591
  if utils.match_response(http_res, "200", "application/json"):
1756
- return utils.unmarshal_json(http_res.text, Any)
1592
+ return unmarshal_json_response(Any, http_res)
1757
1593
  if utils.match_response(http_res, "422", "application/json"):
1758
- response_data = utils.unmarshal_json(
1759
- http_res.text, models.HTTPValidationErrorData
1594
+ response_data = unmarshal_json_response(
1595
+ errors.HTTPValidationErrorData, http_res
1760
1596
  )
1761
- raise models.HTTPValidationError(data=response_data)
1597
+ raise errors.HTTPValidationError(response_data, http_res)
1762
1598
  if utils.match_response(http_res, "4XX", "*"):
1763
1599
  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
- )
1600
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1767
1601
  if utils.match_response(http_res, "5XX", "*"):
1768
1602
  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
- )
1603
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1772
1604
 
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
- )
1605
+ raise errors.APIError("Unexpected response received", http_res)
1781
1606
 
1782
1607
  def remove(
1783
1608
  self,
@@ -1857,31 +1682,20 @@ class Batches(BaseSDK):
1857
1682
 
1858
1683
  response_data: Any = None
1859
1684
  if utils.match_response(http_res, "200", "application/json"):
1860
- return utils.unmarshal_json(http_res.text, Any)
1685
+ return unmarshal_json_response(Any, http_res)
1861
1686
  if utils.match_response(http_res, "422", "application/json"):
1862
- response_data = utils.unmarshal_json(
1863
- http_res.text, models.HTTPValidationErrorData
1687
+ response_data = unmarshal_json_response(
1688
+ errors.HTTPValidationErrorData, http_res
1864
1689
  )
1865
- raise models.HTTPValidationError(data=response_data)
1690
+ raise errors.HTTPValidationError(response_data, http_res)
1866
1691
  if utils.match_response(http_res, "4XX", "*"):
1867
1692
  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
- )
1693
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1871
1694
  if utils.match_response(http_res, "5XX", "*"):
1872
1695
  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
- )
1696
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1876
1697
 
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
- )
1698
+ raise errors.APIError("Unexpected response received", http_res)
1885
1699
 
1886
1700
  async def remove_async(
1887
1701
  self,
@@ -1961,28 +1775,17 @@ class Batches(BaseSDK):
1961
1775
 
1962
1776
  response_data: Any = None
1963
1777
  if utils.match_response(http_res, "200", "application/json"):
1964
- return utils.unmarshal_json(http_res.text, Any)
1778
+ return unmarshal_json_response(Any, http_res)
1965
1779
  if utils.match_response(http_res, "422", "application/json"):
1966
- response_data = utils.unmarshal_json(
1967
- http_res.text, models.HTTPValidationErrorData
1780
+ response_data = unmarshal_json_response(
1781
+ errors.HTTPValidationErrorData, http_res
1968
1782
  )
1969
- raise models.HTTPValidationError(data=response_data)
1783
+ raise errors.HTTPValidationError(response_data, http_res)
1970
1784
  if utils.match_response(http_res, "4XX", "*"):
1971
1785
  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
- )
1786
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1975
1787
  if utils.match_response(http_res, "5XX", "*"):
1976
1788
  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
- )
1789
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1980
1790
 
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
- )
1791
+ raise errors.APIError("Unexpected response received", http_res)