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/test.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, Mapping, Optional, Union, cast
9
10
 
10
11
 
@@ -88,31 +89,20 @@ class Test(BaseSDK):
88
89
 
89
90
  response_data: Any = None
90
91
  if utils.match_response(http_res, "200", "application/json"):
91
- return utils.unmarshal_json(http_res.text, models.TestMessageResponse)
92
+ return unmarshal_json_response(models.TestMessageResponse, http_res)
92
93
  if utils.match_response(http_res, "422", "application/json"):
93
- response_data = utils.unmarshal_json(
94
- http_res.text, models.HTTPValidationErrorData
94
+ response_data = unmarshal_json_response(
95
+ errors.HTTPValidationErrorData, http_res
95
96
  )
96
- raise models.HTTPValidationError(data=response_data)
97
+ raise errors.HTTPValidationError(response_data, http_res)
97
98
  if utils.match_response(http_res, "4XX", "*"):
98
99
  http_res_text = utils.stream_to_text(http_res)
99
- raise models.APIError(
100
- "API error occurred", http_res.status_code, http_res_text, http_res
101
- )
100
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
101
  if utils.match_response(http_res, "5XX", "*"):
103
102
  http_res_text = utils.stream_to_text(http_res)
104
- raise models.APIError(
105
- "API error occurred", http_res.status_code, http_res_text, http_res
106
- )
103
+ raise errors.APIError("API error occurred", http_res, http_res_text)
107
104
 
108
- content_type = http_res.headers.get("Content-Type")
109
- http_res_text = utils.stream_to_text(http_res)
110
- raise models.APIError(
111
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
112
- http_res.status_code,
113
- http_res_text,
114
- http_res,
115
- )
105
+ raise errors.APIError("Unexpected response received", http_res)
116
106
 
117
107
  async def send_test_message_async(
118
108
  self,
@@ -191,28 +181,17 @@ class Test(BaseSDK):
191
181
 
192
182
  response_data: Any = None
193
183
  if utils.match_response(http_res, "200", "application/json"):
194
- return utils.unmarshal_json(http_res.text, models.TestMessageResponse)
184
+ return unmarshal_json_response(models.TestMessageResponse, http_res)
195
185
  if utils.match_response(http_res, "422", "application/json"):
196
- response_data = utils.unmarshal_json(
197
- http_res.text, models.HTTPValidationErrorData
186
+ response_data = unmarshal_json_response(
187
+ errors.HTTPValidationErrorData, http_res
198
188
  )
199
- raise models.HTTPValidationError(data=response_data)
189
+ raise errors.HTTPValidationError(response_data, http_res)
200
190
  if utils.match_response(http_res, "4XX", "*"):
201
191
  http_res_text = await utils.stream_to_text_async(http_res)
202
- raise models.APIError(
203
- "API error occurred", http_res.status_code, http_res_text, http_res
204
- )
192
+ raise errors.APIError("API error occurred", http_res, http_res_text)
205
193
  if utils.match_response(http_res, "5XX", "*"):
206
194
  http_res_text = await utils.stream_to_text_async(http_res)
207
- raise models.APIError(
208
- "API error occurred", http_res.status_code, http_res_text, http_res
209
- )
195
+ raise errors.APIError("API error occurred", http_res, http_res_text)
210
196
 
211
- content_type = http_res.headers.get("Content-Type")
212
- http_res_text = await utils.stream_to_text_async(http_res)
213
- raise models.APIError(
214
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
215
- http_res.status_code,
216
- http_res_text,
217
- http_res,
218
- )
197
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/tools.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
 
@@ -109,31 +110,20 @@ class Tools(BaseSDK):
109
110
 
110
111
  response_data: Any = None
111
112
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(http_res.text, models.ListResponseToolResponse)
113
+ return unmarshal_json_response(models.ListResponseToolResponse, http_res)
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,
@@ -233,31 +223,20 @@ class Tools(BaseSDK):
233
223
 
234
224
  response_data: Any = None
235
225
  if utils.match_response(http_res, "200", "application/json"):
236
- return utils.unmarshal_json(http_res.text, models.ListResponseToolResponse)
226
+ return unmarshal_json_response(models.ListResponseToolResponse, http_res)
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 Tools(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.ToolResponse)
318
+ return unmarshal_json_response(models.ToolResponse, 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 Tools(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.ToolResponse)
410
+ return unmarshal_json_response(models.ToolResponse, 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 update(
469
426
  self,
@@ -542,31 +499,20 @@ class Tools(BaseSDK):
542
499
 
543
500
  response_data: Any = None
544
501
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
502
+ return unmarshal_json_response(models.ToolResponse, http_res)
546
503
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
504
+ response_data = unmarshal_json_response(
505
+ errors.HTTPValidationErrorData, http_res
549
506
  )
550
- raise models.HTTPValidationError(data=response_data)
507
+ raise errors.HTTPValidationError(response_data, http_res)
551
508
  if utils.match_response(http_res, "4XX", "*"):
552
509
  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
- )
510
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
511
  if utils.match_response(http_res, "5XX", "*"):
557
512
  http_res_text = utils.stream_to_text(http_res)
558
- raise models.APIError(
559
- "API error occurred", http_res.status_code, http_res_text, http_res
560
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
514
 
562
- content_type = http_res.headers.get("Content-Type")
563
- http_res_text = utils.stream_to_text(http_res)
564
- raise models.APIError(
565
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
566
- http_res.status_code,
567
- http_res_text,
568
- http_res,
569
- )
515
+ raise errors.APIError("Unexpected response received", http_res)
570
516
 
571
517
  async def update_async(
572
518
  self,
@@ -645,31 +591,20 @@ class Tools(BaseSDK):
645
591
 
646
592
  response_data: Any = None
647
593
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
594
+ return unmarshal_json_response(models.ToolResponse, http_res)
649
595
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
596
+ response_data = unmarshal_json_response(
597
+ errors.HTTPValidationErrorData, http_res
652
598
  )
653
- raise models.HTTPValidationError(data=response_data)
599
+ raise errors.HTTPValidationError(response_data, http_res)
654
600
  if utils.match_response(http_res, "4XX", "*"):
655
601
  http_res_text = await utils.stream_to_text_async(http_res)
656
- raise models.APIError(
657
- "API error occurred", http_res.status_code, http_res_text, http_res
658
- )
602
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
603
  if utils.match_response(http_res, "5XX", "*"):
660
604
  http_res_text = await utils.stream_to_text_async(http_res)
661
- raise models.APIError(
662
- "API error occurred", http_res.status_code, http_res_text, http_res
663
- )
605
+ raise errors.APIError("API error occurred", http_res, http_res_text)
664
606
 
665
- content_type = http_res.headers.get("Content-Type")
666
- http_res_text = await utils.stream_to_text_async(http_res)
667
- raise models.APIError(
668
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
669
- http_res.status_code,
670
- http_res_text,
671
- http_res,
672
- )
607
+ raise errors.APIError("Unexpected response received", http_res)
673
608
 
674
609
  def get_by_name(
675
610
  self,
@@ -745,31 +680,20 @@ class Tools(BaseSDK):
745
680
 
746
681
  response_data: Any = None
747
682
  if utils.match_response(http_res, "200", "application/json"):
748
- return utils.unmarshal_json(http_res.text, models.ToolDetailResponse)
683
+ return unmarshal_json_response(models.ToolDetailResponse, http_res)
749
684
  if utils.match_response(http_res, "422", "application/json"):
750
- response_data = utils.unmarshal_json(
751
- http_res.text, models.HTTPValidationErrorData
685
+ response_data = unmarshal_json_response(
686
+ errors.HTTPValidationErrorData, http_res
752
687
  )
753
- raise models.HTTPValidationError(data=response_data)
688
+ raise errors.HTTPValidationError(response_data, http_res)
754
689
  if utils.match_response(http_res, "4XX", "*"):
755
690
  http_res_text = utils.stream_to_text(http_res)
756
- raise models.APIError(
757
- "API error occurred", http_res.status_code, http_res_text, http_res
758
- )
691
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
692
  if utils.match_response(http_res, "5XX", "*"):
760
693
  http_res_text = utils.stream_to_text(http_res)
761
- raise models.APIError(
762
- "API error occurred", http_res.status_code, http_res_text, http_res
763
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
764
695
 
765
- content_type = http_res.headers.get("Content-Type")
766
- http_res_text = utils.stream_to_text(http_res)
767
- raise models.APIError(
768
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
769
- http_res.status_code,
770
- http_res_text,
771
- http_res,
772
- )
696
+ raise errors.APIError("Unexpected response received", http_res)
773
697
 
774
698
  async def get_by_name_async(
775
699
  self,
@@ -845,31 +769,20 @@ class Tools(BaseSDK):
845
769
 
846
770
  response_data: Any = None
847
771
  if utils.match_response(http_res, "200", "application/json"):
848
- return utils.unmarshal_json(http_res.text, models.ToolDetailResponse)
772
+ return unmarshal_json_response(models.ToolDetailResponse, http_res)
849
773
  if utils.match_response(http_res, "422", "application/json"):
850
- response_data = utils.unmarshal_json(
851
- http_res.text, models.HTTPValidationErrorData
774
+ response_data = unmarshal_json_response(
775
+ errors.HTTPValidationErrorData, http_res
852
776
  )
853
- raise models.HTTPValidationError(data=response_data)
777
+ raise errors.HTTPValidationError(response_data, http_res)
854
778
  if utils.match_response(http_res, "4XX", "*"):
855
779
  http_res_text = await utils.stream_to_text_async(http_res)
856
- raise models.APIError(
857
- "API error occurred", http_res.status_code, http_res_text, http_res
858
- )
780
+ raise errors.APIError("API error occurred", http_res, http_res_text)
859
781
  if utils.match_response(http_res, "5XX", "*"):
860
782
  http_res_text = await utils.stream_to_text_async(http_res)
861
- raise models.APIError(
862
- "API error occurred", http_res.status_code, http_res_text, http_res
863
- )
783
+ raise errors.APIError("API error occurred", http_res, http_res_text)
864
784
 
865
- content_type = http_res.headers.get("Content-Type")
866
- http_res_text = await utils.stream_to_text_async(http_res)
867
- raise models.APIError(
868
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
869
- http_res.status_code,
870
- http_res_text,
871
- http_res,
872
- )
785
+ raise errors.APIError("Unexpected response received", http_res)
873
786
 
874
787
  def delete(
875
788
  self,
@@ -948,31 +861,20 @@ class Tools(BaseSDK):
948
861
 
949
862
  response_data: Any = None
950
863
  if utils.match_response(http_res, "200", "application/json"):
951
- return utils.unmarshal_json(http_res.text, Any)
864
+ return unmarshal_json_response(Any, http_res)
952
865
  if utils.match_response(http_res, "422", "application/json"):
953
- response_data = utils.unmarshal_json(
954
- http_res.text, models.HTTPValidationErrorData
866
+ response_data = unmarshal_json_response(
867
+ errors.HTTPValidationErrorData, http_res
955
868
  )
956
- raise models.HTTPValidationError(data=response_data)
869
+ raise errors.HTTPValidationError(response_data, http_res)
957
870
  if utils.match_response(http_res, "4XX", "*"):
958
871
  http_res_text = utils.stream_to_text(http_res)
959
- raise models.APIError(
960
- "API error occurred", http_res.status_code, http_res_text, http_res
961
- )
872
+ raise errors.APIError("API error occurred", http_res, http_res_text)
962
873
  if utils.match_response(http_res, "5XX", "*"):
963
874
  http_res_text = utils.stream_to_text(http_res)
964
- raise models.APIError(
965
- "API error occurred", http_res.status_code, http_res_text, http_res
966
- )
875
+ raise errors.APIError("API error occurred", http_res, http_res_text)
967
876
 
968
- content_type = http_res.headers.get("Content-Type")
969
- http_res_text = utils.stream_to_text(http_res)
970
- raise models.APIError(
971
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
972
- http_res.status_code,
973
- http_res_text,
974
- http_res,
975
- )
877
+ raise errors.APIError("Unexpected response received", http_res)
976
878
 
977
879
  async def delete_async(
978
880
  self,
@@ -1051,28 +953,17 @@ class Tools(BaseSDK):
1051
953
 
1052
954
  response_data: Any = None
1053
955
  if utils.match_response(http_res, "200", "application/json"):
1054
- return utils.unmarshal_json(http_res.text, Any)
956
+ return unmarshal_json_response(Any, http_res)
1055
957
  if utils.match_response(http_res, "422", "application/json"):
1056
- response_data = utils.unmarshal_json(
1057
- http_res.text, models.HTTPValidationErrorData
958
+ response_data = unmarshal_json_response(
959
+ errors.HTTPValidationErrorData, http_res
1058
960
  )
1059
- raise models.HTTPValidationError(data=response_data)
961
+ raise errors.HTTPValidationError(response_data, http_res)
1060
962
  if utils.match_response(http_res, "4XX", "*"):
1061
963
  http_res_text = await utils.stream_to_text_async(http_res)
1062
- raise models.APIError(
1063
- "API error occurred", http_res.status_code, http_res_text, http_res
1064
- )
964
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1065
965
  if utils.match_response(http_res, "5XX", "*"):
1066
966
  http_res_text = await utils.stream_to_text_async(http_res)
1067
- raise models.APIError(
1068
- "API error occurred", http_res.status_code, http_res_text, http_res
1069
- )
967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1070
968
 
1071
- content_type = http_res.headers.get("Content-Type")
1072
- http_res_text = await utils.stream_to_text_async(http_res)
1073
- raise models.APIError(
1074
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1075
- http_res.status_code,
1076
- http_res_text,
1077
- http_res,
1078
- )
969
+ raise errors.APIError("Unexpected response received", http_res)
@@ -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 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, Mapping, Optional
9
10
 
10
11
 
@@ -81,33 +82,22 @@ class Transcript(BaseSDK):
81
82
 
82
83
  response_data: Any = None
83
84
  if utils.match_response(http_res, "200", "application/json"):
84
- return utils.unmarshal_json(
85
- http_res.text, models.SessionTranscriptionResponse
85
+ return unmarshal_json_response(
86
+ models.SessionTranscriptionResponse, http_res
86
87
  )
87
88
  if utils.match_response(http_res, "422", "application/json"):
88
- response_data = utils.unmarshal_json(
89
- http_res.text, models.HTTPValidationErrorData
89
+ response_data = unmarshal_json_response(
90
+ errors.HTTPValidationErrorData, http_res
90
91
  )
91
- raise models.HTTPValidationError(data=response_data)
92
+ raise errors.HTTPValidationError(response_data, http_res)
92
93
  if utils.match_response(http_res, "4XX", "*"):
93
94
  http_res_text = utils.stream_to_text(http_res)
94
- raise models.APIError(
95
- "API error occurred", http_res.status_code, http_res_text, http_res
96
- )
95
+ raise errors.APIError("API error occurred", http_res, http_res_text)
97
96
  if utils.match_response(http_res, "5XX", "*"):
98
97
  http_res_text = utils.stream_to_text(http_res)
99
- raise models.APIError(
100
- "API error occurred", http_res.status_code, http_res_text, http_res
101
- )
98
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
99
 
103
- content_type = http_res.headers.get("Content-Type")
104
- http_res_text = utils.stream_to_text(http_res)
105
- raise models.APIError(
106
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
107
- http_res.status_code,
108
- http_res_text,
109
- http_res,
110
- )
100
+ raise errors.APIError("Unexpected response received", http_res)
111
101
 
112
102
  async def get_by_id_async(
113
103
  self,
@@ -181,30 +171,19 @@ class Transcript(BaseSDK):
181
171
 
182
172
  response_data: Any = None
183
173
  if utils.match_response(http_res, "200", "application/json"):
184
- return utils.unmarshal_json(
185
- http_res.text, models.SessionTranscriptionResponse
174
+ return unmarshal_json_response(
175
+ models.SessionTranscriptionResponse, http_res
186
176
  )
187
177
  if utils.match_response(http_res, "422", "application/json"):
188
- response_data = utils.unmarshal_json(
189
- http_res.text, models.HTTPValidationErrorData
178
+ response_data = unmarshal_json_response(
179
+ errors.HTTPValidationErrorData, http_res
190
180
  )
191
- raise models.HTTPValidationError(data=response_data)
181
+ raise errors.HTTPValidationError(response_data, http_res)
192
182
  if utils.match_response(http_res, "4XX", "*"):
193
183
  http_res_text = await utils.stream_to_text_async(http_res)
194
- raise models.APIError(
195
- "API error occurred", http_res.status_code, http_res_text, http_res
196
- )
184
+ raise errors.APIError("API error occurred", http_res, http_res_text)
197
185
  if utils.match_response(http_res, "5XX", "*"):
198
186
  http_res_text = await utils.stream_to_text_async(http_res)
199
- raise models.APIError(
200
- "API error occurred", http_res.status_code, http_res_text, http_res
201
- )
187
+ raise errors.APIError("API error occurred", http_res, http_res_text)
202
188
 
203
- content_type = http_res.headers.get("Content-Type")
204
- http_res_text = await utils.stream_to_text_async(http_res)
205
- raise models.APIError(
206
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
207
- http_res.status_code,
208
- http_res_text,
209
- http_res,
210
- )
189
+ raise errors.APIError("Unexpected response received", http_res)