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/campaigns.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 Campaigns(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.ListResponseOutboundCampaign
110
+ return utils.unmarshal_json_response(
111
+ models.ListResponseOutboundCampaign, 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 Campaigns(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.ListResponseOutboundCampaign
223
+ return utils.unmarshal_json_response(
224
+ models.ListResponseOutboundCampaign, 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 Campaigns(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.OutboundCampaign)
317
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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 Campaigns(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.OutboundCampaign)
409
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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 Campaigns(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.OutboundCampaign)
496
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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 Campaigns(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.OutboundCampaign)
583
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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 Campaigns(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.OutboundCampaign)
684
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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 Campaigns(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.OutboundCampaign)
785
+ return utils.unmarshal_json_response(models.OutboundCampaign, 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,
@@ -957,31 +869,20 @@ class Campaigns(BaseSDK):
957
869
 
958
870
  response_data: Any = None
959
871
  if utils.match_response(http_res, "200", "application/json"):
960
- return utils.unmarshal_json(http_res.text, Any)
872
+ return utils.unmarshal_json_response(Any, http_res)
961
873
  if utils.match_response(http_res, "422", "application/json"):
962
- response_data = utils.unmarshal_json(
963
- http_res.text, models.HTTPValidationErrorData
874
+ response_data = utils.unmarshal_json_response(
875
+ errors.HTTPValidationErrorData, http_res
964
876
  )
965
- raise models.HTTPValidationError(data=response_data)
877
+ raise errors.HTTPValidationError(response_data, http_res)
966
878
  if utils.match_response(http_res, "4XX", "*"):
967
879
  http_res_text = utils.stream_to_text(http_res)
968
- raise models.APIError(
969
- "API error occurred", http_res.status_code, http_res_text, http_res
970
- )
880
+ raise errors.APIError("API error occurred", http_res, http_res_text)
971
881
  if utils.match_response(http_res, "5XX", "*"):
972
882
  http_res_text = utils.stream_to_text(http_res)
973
- raise models.APIError(
974
- "API error occurred", http_res.status_code, http_res_text, http_res
975
- )
883
+ raise errors.APIError("API error occurred", http_res, http_res_text)
976
884
 
977
- content_type = http_res.headers.get("Content-Type")
978
- http_res_text = utils.stream_to_text(http_res)
979
- raise models.APIError(
980
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
981
- http_res.status_code,
982
- http_res_text,
983
- http_res,
984
- )
885
+ raise errors.APIError("Unexpected response received", http_res)
985
886
 
986
887
  async def delete_async(
987
888
  self,
@@ -1055,28 +956,17 @@ class Campaigns(BaseSDK):
1055
956
 
1056
957
  response_data: Any = None
1057
958
  if utils.match_response(http_res, "200", "application/json"):
1058
- return utils.unmarshal_json(http_res.text, Any)
959
+ return utils.unmarshal_json_response(Any, http_res)
1059
960
  if utils.match_response(http_res, "422", "application/json"):
1060
- response_data = utils.unmarshal_json(
1061
- http_res.text, models.HTTPValidationErrorData
961
+ response_data = utils.unmarshal_json_response(
962
+ errors.HTTPValidationErrorData, http_res
1062
963
  )
1063
- raise models.HTTPValidationError(data=response_data)
964
+ raise errors.HTTPValidationError(response_data, http_res)
1064
965
  if utils.match_response(http_res, "4XX", "*"):
1065
966
  http_res_text = await utils.stream_to_text_async(http_res)
1066
- raise models.APIError(
1067
- "API error occurred", http_res.status_code, http_res_text, http_res
1068
- )
967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1069
968
  if utils.match_response(http_res, "5XX", "*"):
1070
969
  http_res_text = await utils.stream_to_text_async(http_res)
1071
- raise models.APIError(
1072
- "API error occurred", http_res.status_code, http_res_text, http_res
1073
- )
970
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1074
971
 
1075
- content_type = http_res.headers.get("Content-Type")
1076
- http_res_text = await utils.stream_to_text_async(http_res)
1077
- raise models.APIError(
1078
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1079
- http_res.status_code,
1080
- http_res_text,
1081
- http_res,
1082
- )
972
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/channels.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  from .basesdk import BaseSDK
4
4
  from .sdkconfiguration import SDKConfiguration
5
- from syllable_sdk import models, utils
5
+ from syllable_sdk import errors, models, utils
6
6
  from syllable_sdk._hooks import HookContext
7
7
  from syllable_sdk.targets import Targets
8
8
  from syllable_sdk.twilio import Twilio
@@ -124,31 +124,20 @@ class Channels(BaseSDK):
124
124
 
125
125
  response_data: Any = None
126
126
  if utils.match_response(http_res, "200", "application/json"):
127
- return utils.unmarshal_json(http_res.text, models.ListResponseChannel)
127
+ return utils.unmarshal_json_response(models.ListResponseChannel, http_res)
128
128
  if utils.match_response(http_res, "422", "application/json"):
129
- response_data = utils.unmarshal_json(
130
- http_res.text, models.HTTPValidationErrorData
129
+ response_data = utils.unmarshal_json_response(
130
+ errors.HTTPValidationErrorData, http_res
131
131
  )
132
- raise models.HTTPValidationError(data=response_data)
132
+ raise errors.HTTPValidationError(response_data, http_res)
133
133
  if utils.match_response(http_res, "4XX", "*"):
134
134
  http_res_text = utils.stream_to_text(http_res)
135
- raise models.APIError(
136
- "API error occurred", http_res.status_code, http_res_text, http_res
137
- )
135
+ raise errors.APIError("API error occurred", http_res, http_res_text)
138
136
  if utils.match_response(http_res, "5XX", "*"):
139
137
  http_res_text = utils.stream_to_text(http_res)
140
- raise models.APIError(
141
- "API error occurred", http_res.status_code, http_res_text, http_res
142
- )
138
+ raise errors.APIError("API error occurred", http_res, http_res_text)
143
139
 
144
- content_type = http_res.headers.get("Content-Type")
145
- http_res_text = utils.stream_to_text(http_res)
146
- raise models.APIError(
147
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
148
- http_res.status_code,
149
- http_res_text,
150
- http_res,
151
- )
140
+ raise errors.APIError("Unexpected response received", http_res)
152
141
 
153
142
  async def list_async(
154
143
  self,
@@ -246,31 +235,20 @@ class Channels(BaseSDK):
246
235
 
247
236
  response_data: Any = None
248
237
  if utils.match_response(http_res, "200", "application/json"):
249
- return utils.unmarshal_json(http_res.text, models.ListResponseChannel)
238
+ return utils.unmarshal_json_response(models.ListResponseChannel, http_res)
250
239
  if utils.match_response(http_res, "422", "application/json"):
251
- response_data = utils.unmarshal_json(
252
- http_res.text, models.HTTPValidationErrorData
240
+ response_data = utils.unmarshal_json_response(
241
+ errors.HTTPValidationErrorData, http_res
253
242
  )
254
- raise models.HTTPValidationError(data=response_data)
243
+ raise errors.HTTPValidationError(response_data, http_res)
255
244
  if utils.match_response(http_res, "4XX", "*"):
256
245
  http_res_text = await utils.stream_to_text_async(http_res)
257
- raise models.APIError(
258
- "API error occurred", http_res.status_code, http_res_text, http_res
259
- )
246
+ raise errors.APIError("API error occurred", http_res, http_res_text)
260
247
  if utils.match_response(http_res, "5XX", "*"):
261
248
  http_res_text = await utils.stream_to_text_async(http_res)
262
- raise models.APIError(
263
- "API error occurred", http_res.status_code, http_res_text, http_res
264
- )
249
+ raise errors.APIError("API error occurred", http_res, http_res_text)
265
250
 
266
- content_type = http_res.headers.get("Content-Type")
267
- http_res_text = await utils.stream_to_text_async(http_res)
268
- raise models.APIError(
269
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
270
- http_res.status_code,
271
- http_res_text,
272
- http_res,
273
- )
251
+ raise errors.APIError("Unexpected response received", http_res)
274
252
 
275
253
  def delete(
276
254
  self,
@@ -349,31 +327,20 @@ class Channels(BaseSDK):
349
327
 
350
328
  response_data: Any = None
351
329
  if utils.match_response(http_res, "200", "application/json"):
352
- return utils.unmarshal_json(http_res.text, Any)
330
+ return utils.unmarshal_json_response(Any, http_res)
353
331
  if utils.match_response(http_res, "422", "application/json"):
354
- response_data = utils.unmarshal_json(
355
- http_res.text, models.HTTPValidationErrorData
332
+ response_data = utils.unmarshal_json_response(
333
+ errors.HTTPValidationErrorData, http_res
356
334
  )
357
- raise models.HTTPValidationError(data=response_data)
335
+ raise errors.HTTPValidationError(response_data, http_res)
358
336
  if utils.match_response(http_res, "4XX", "*"):
359
337
  http_res_text = utils.stream_to_text(http_res)
360
- raise models.APIError(
361
- "API error occurred", http_res.status_code, http_res_text, http_res
362
- )
338
+ raise errors.APIError("API error occurred", http_res, http_res_text)
363
339
  if utils.match_response(http_res, "5XX", "*"):
364
340
  http_res_text = utils.stream_to_text(http_res)
365
- raise models.APIError(
366
- "API error occurred", http_res.status_code, http_res_text, http_res
367
- )
341
+ raise errors.APIError("API error occurred", http_res, http_res_text)
368
342
 
369
- content_type = http_res.headers.get("Content-Type")
370
- http_res_text = utils.stream_to_text(http_res)
371
- raise models.APIError(
372
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
373
- http_res.status_code,
374
- http_res_text,
375
- http_res,
376
- )
343
+ raise errors.APIError("Unexpected response received", http_res)
377
344
 
378
345
  async def delete_async(
379
346
  self,
@@ -452,28 +419,17 @@ class Channels(BaseSDK):
452
419
 
453
420
  response_data: Any = None
454
421
  if utils.match_response(http_res, "200", "application/json"):
455
- return utils.unmarshal_json(http_res.text, Any)
422
+ return utils.unmarshal_json_response(Any, http_res)
456
423
  if utils.match_response(http_res, "422", "application/json"):
457
- response_data = utils.unmarshal_json(
458
- http_res.text, models.HTTPValidationErrorData
424
+ response_data = utils.unmarshal_json_response(
425
+ errors.HTTPValidationErrorData, http_res
459
426
  )
460
- raise models.HTTPValidationError(data=response_data)
427
+ raise errors.HTTPValidationError(response_data, http_res)
461
428
  if utils.match_response(http_res, "4XX", "*"):
462
429
  http_res_text = await utils.stream_to_text_async(http_res)
463
- raise models.APIError(
464
- "API error occurred", http_res.status_code, http_res_text, http_res
465
- )
430
+ raise errors.APIError("API error occurred", http_res, http_res_text)
466
431
  if utils.match_response(http_res, "5XX", "*"):
467
432
  http_res_text = await utils.stream_to_text_async(http_res)
468
- raise models.APIError(
469
- "API error occurred", http_res.status_code, http_res_text, http_res
470
- )
433
+ raise errors.APIError("API error occurred", http_res, http_res_text)
471
434
 
472
- content_type = http_res.headers.get("Content-Type")
473
- http_res_text = await utils.stream_to_text_async(http_res)
474
- raise models.APIError(
475
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
476
- http_res.status_code,
477
- http_res_text,
478
- http_res,
479
- )
435
+ raise errors.APIError("Unexpected response received", http_res)
@@ -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 OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -107,31 +107,22 @@ class Conversations(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.ListResponseConversation)
110
+ return utils.unmarshal_json_response(
111
+ models.ListResponseConversation, 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,
@@ -229,28 +220,19 @@ class Conversations(BaseSDK):
229
220
 
230
221
  response_data: Any = None
231
222
  if utils.match_response(http_res, "200", "application/json"):
232
- return utils.unmarshal_json(http_res.text, models.ListResponseConversation)
223
+ return utils.unmarshal_json_response(
224
+ models.ListResponseConversation, http_res
225
+ )
233
226
  if utils.match_response(http_res, "422", "application/json"):
234
- response_data = utils.unmarshal_json(
235
- http_res.text, models.HTTPValidationErrorData
227
+ response_data = utils.unmarshal_json_response(
228
+ errors.HTTPValidationErrorData, http_res
236
229
  )
237
- raise models.HTTPValidationError(data=response_data)
230
+ raise errors.HTTPValidationError(response_data, http_res)
238
231
  if utils.match_response(http_res, "4XX", "*"):
239
232
  http_res_text = await utils.stream_to_text_async(http_res)
240
- raise models.APIError(
241
- "API error occurred", http_res.status_code, http_res_text, http_res
242
- )
233
+ raise errors.APIError("API error occurred", http_res, http_res_text)
243
234
  if utils.match_response(http_res, "5XX", "*"):
244
235
  http_res_text = await utils.stream_to_text_async(http_res)
245
- raise models.APIError(
246
- "API error occurred", http_res.status_code, http_res_text, http_res
247
- )
236
+ raise errors.APIError("API error occurred", http_res, http_res_text)
248
237
 
249
- content_type = http_res.headers.get("Content-Type")
250
- http_res_text = await utils.stream_to_text_async(http_res)
251
- raise models.APIError(
252
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
253
- http_res.status_code,
254
- http_res_text,
255
- http_res,
256
- )
238
+ raise errors.APIError("Unexpected response received", http_res)