syllable-sdk 0.35.32__py3-none-any.whl → 0.35.33__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. syllable_sdk/__init__.py +0 -1
  2. syllable_sdk/_version.py +3 -3
  3. syllable_sdk/agents.py +83 -211
  4. syllable_sdk/basesdk.py +5 -5
  5. syllable_sdk/batches.py +131 -329
  6. syllable_sdk/campaigns.py +73 -183
  7. syllable_sdk/channels.py +29 -73
  8. syllable_sdk/conversations.py +19 -37
  9. syllable_sdk/custom_messages.py +73 -183
  10. syllable_sdk/dashboards.py +67 -195
  11. syllable_sdk/data_sources.py +85 -183
  12. syllable_sdk/errors/__init__.py +55 -0
  13. syllable_sdk/errors/apierror.py +38 -0
  14. syllable_sdk/errors/httpvalidationerror.py +26 -0
  15. syllable_sdk/errors/no_response_error.py +13 -0
  16. syllable_sdk/errors/responsevalidationerror.py +25 -0
  17. syllable_sdk/errors/syllablesdkerror.py +26 -0
  18. syllable_sdk/events.py +15 -37
  19. syllable_sdk/folders.py +121 -293
  20. syllable_sdk/full_summary.py +19 -37
  21. syllable_sdk/incidents.py +83 -215
  22. syllable_sdk/insights_sdk.py +17 -39
  23. syllable_sdk/insights_tools.py +97 -251
  24. syllable_sdk/language_groups.py +85 -215
  25. syllable_sdk/latency.py +19 -37
  26. syllable_sdk/models/__init__.py +0 -8
  27. syllable_sdk/numbers.py +53 -111
  28. syllable_sdk/organizations.py +51 -139
  29. syllable_sdk/permissions.py +11 -33
  30. syllable_sdk/prompts.py +95 -249
  31. syllable_sdk/roles.py +75 -181
  32. syllable_sdk/services.py +73 -183
  33. syllable_sdk/session_debug.py +43 -109
  34. syllable_sdk/session_labels.py +47 -109
  35. syllable_sdk/sessions.py +59 -141
  36. syllable_sdk/takeouts.py +35 -99
  37. syllable_sdk/targets.py +75 -185
  38. syllable_sdk/test.py +15 -37
  39. syllable_sdk/tools.py +75 -181
  40. syllable_sdk/transcript.py +17 -39
  41. syllable_sdk/twilio.py +43 -109
  42. syllable_sdk/users.py +97 -247
  43. syllable_sdk/utils/__init__.py +3 -0
  44. syllable_sdk/utils/serializers.py +21 -3
  45. syllable_sdk/v1.py +97 -247
  46. syllable_sdk/workflows.py +115 -291
  47. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/METADATA +58 -45
  48. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/RECORD +49 -45
  49. syllable_sdk/models/apierror.py +0 -22
  50. syllable_sdk/models/httpvalidationerror.py +0 -21
  51. {syllable_sdk-0.35.32.dist-info → syllable_sdk-0.35.33.dist-info}/WHEEL +0 -0
syllable_sdk/test.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
@@ -88,31 +88,20 @@ class Test(BaseSDK):
88
88
 
89
89
  response_data: Any = None
90
90
  if utils.match_response(http_res, "200", "application/json"):
91
- return utils.unmarshal_json(http_res.text, models.TestMessageResponse)
91
+ return utils.unmarshal_json_response(models.TestMessageResponse, http_res)
92
92
  if utils.match_response(http_res, "422", "application/json"):
93
- response_data = utils.unmarshal_json(
94
- http_res.text, models.HTTPValidationErrorData
93
+ response_data = utils.unmarshal_json_response(
94
+ errors.HTTPValidationErrorData, http_res
95
95
  )
96
- raise models.HTTPValidationError(data=response_data)
96
+ raise errors.HTTPValidationError(response_data, http_res)
97
97
  if utils.match_response(http_res, "4XX", "*"):
98
98
  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
- )
99
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
100
  if utils.match_response(http_res, "5XX", "*"):
103
101
  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
- )
102
+ raise errors.APIError("API error occurred", http_res, http_res_text)
107
103
 
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
- )
104
+ raise errors.APIError("Unexpected response received", http_res)
116
105
 
117
106
  async def send_test_message_async(
118
107
  self,
@@ -191,28 +180,17 @@ class Test(BaseSDK):
191
180
 
192
181
  response_data: Any = None
193
182
  if utils.match_response(http_res, "200", "application/json"):
194
- return utils.unmarshal_json(http_res.text, models.TestMessageResponse)
183
+ return utils.unmarshal_json_response(models.TestMessageResponse, http_res)
195
184
  if utils.match_response(http_res, "422", "application/json"):
196
- response_data = utils.unmarshal_json(
197
- http_res.text, models.HTTPValidationErrorData
185
+ response_data = utils.unmarshal_json_response(
186
+ errors.HTTPValidationErrorData, http_res
198
187
  )
199
- raise models.HTTPValidationError(data=response_data)
188
+ raise errors.HTTPValidationError(response_data, http_res)
200
189
  if utils.match_response(http_res, "4XX", "*"):
201
190
  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
- )
191
+ raise errors.APIError("API error occurred", http_res, http_res_text)
205
192
  if utils.match_response(http_res, "5XX", "*"):
206
193
  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
- )
194
+ raise errors.APIError("API error occurred", http_res, http_res_text)
210
195
 
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
- )
196
+ raise errors.APIError("Unexpected response received", http_res)
syllable_sdk/tools.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
@@ -109,31 +109,22 @@ class Tools(BaseSDK):
109
109
 
110
110
  response_data: Any = None
111
111
  if utils.match_response(http_res, "200", "application/json"):
112
- return utils.unmarshal_json(http_res.text, models.ListResponseToolResponse)
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseToolResponse, http_res
114
+ )
113
115
  if utils.match_response(http_res, "422", "application/json"):
114
- response_data = utils.unmarshal_json(
115
- http_res.text, models.HTTPValidationErrorData
116
+ response_data = utils.unmarshal_json_response(
117
+ errors.HTTPValidationErrorData, http_res
116
118
  )
117
- raise models.HTTPValidationError(data=response_data)
119
+ raise errors.HTTPValidationError(response_data, http_res)
118
120
  if utils.match_response(http_res, "4XX", "*"):
119
121
  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
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
123
123
  if utils.match_response(http_res, "5XX", "*"):
124
124
  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
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
128
126
 
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
- )
127
+ raise errors.APIError("Unexpected response received", http_res)
137
128
 
138
129
  async def list_async(
139
130
  self,
@@ -233,31 +224,22 @@ class Tools(BaseSDK):
233
224
 
234
225
  response_data: Any = None
235
226
  if utils.match_response(http_res, "200", "application/json"):
236
- return utils.unmarshal_json(http_res.text, models.ListResponseToolResponse)
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseToolResponse, http_res
229
+ )
237
230
  if utils.match_response(http_res, "422", "application/json"):
238
- response_data = utils.unmarshal_json(
239
- http_res.text, models.HTTPValidationErrorData
231
+ response_data = utils.unmarshal_json_response(
232
+ errors.HTTPValidationErrorData, http_res
240
233
  )
241
- raise models.HTTPValidationError(data=response_data)
234
+ raise errors.HTTPValidationError(response_data, http_res)
242
235
  if utils.match_response(http_res, "4XX", "*"):
243
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
247
238
  if utils.match_response(http_res, "5XX", "*"):
248
239
  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
- )
240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
252
241
 
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
- )
242
+ raise errors.APIError("Unexpected response received", http_res)
261
243
 
262
244
  def create(
263
245
  self,
@@ -336,31 +318,20 @@ class Tools(BaseSDK):
336
318
 
337
319
  response_data: Any = None
338
320
  if utils.match_response(http_res, "200", "application/json"):
339
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
321
+ return utils.unmarshal_json_response(models.ToolResponse, http_res)
340
322
  if utils.match_response(http_res, "422", "application/json"):
341
- response_data = utils.unmarshal_json(
342
- http_res.text, models.HTTPValidationErrorData
323
+ response_data = utils.unmarshal_json_response(
324
+ errors.HTTPValidationErrorData, http_res
343
325
  )
344
- raise models.HTTPValidationError(data=response_data)
326
+ raise errors.HTTPValidationError(response_data, http_res)
345
327
  if utils.match_response(http_res, "4XX", "*"):
346
328
  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
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
350
330
  if utils.match_response(http_res, "5XX", "*"):
351
331
  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
- )
332
+ raise errors.APIError("API error occurred", http_res, http_res_text)
355
333
 
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
- )
334
+ raise errors.APIError("Unexpected response received", http_res)
364
335
 
365
336
  async def create_async(
366
337
  self,
@@ -439,31 +410,20 @@ class Tools(BaseSDK):
439
410
 
440
411
  response_data: Any = None
441
412
  if utils.match_response(http_res, "200", "application/json"):
442
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
413
+ return utils.unmarshal_json_response(models.ToolResponse, http_res)
443
414
  if utils.match_response(http_res, "422", "application/json"):
444
- response_data = utils.unmarshal_json(
445
- http_res.text, models.HTTPValidationErrorData
415
+ response_data = utils.unmarshal_json_response(
416
+ errors.HTTPValidationErrorData, http_res
446
417
  )
447
- raise models.HTTPValidationError(data=response_data)
418
+ raise errors.HTTPValidationError(response_data, http_res)
448
419
  if utils.match_response(http_res, "4XX", "*"):
449
420
  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
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
453
422
  if utils.match_response(http_res, "5XX", "*"):
454
423
  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
- )
424
+ raise errors.APIError("API error occurred", http_res, http_res_text)
458
425
 
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
- )
426
+ raise errors.APIError("Unexpected response received", http_res)
467
427
 
468
428
  def update(
469
429
  self,
@@ -542,31 +502,20 @@ class Tools(BaseSDK):
542
502
 
543
503
  response_data: Any = None
544
504
  if utils.match_response(http_res, "200", "application/json"):
545
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
505
+ return utils.unmarshal_json_response(models.ToolResponse, http_res)
546
506
  if utils.match_response(http_res, "422", "application/json"):
547
- response_data = utils.unmarshal_json(
548
- http_res.text, models.HTTPValidationErrorData
507
+ response_data = utils.unmarshal_json_response(
508
+ errors.HTTPValidationErrorData, http_res
549
509
  )
550
- raise models.HTTPValidationError(data=response_data)
510
+ raise errors.HTTPValidationError(response_data, http_res)
551
511
  if utils.match_response(http_res, "4XX", "*"):
552
512
  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
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
556
514
  if utils.match_response(http_res, "5XX", "*"):
557
515
  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
- )
516
+ raise errors.APIError("API error occurred", http_res, http_res_text)
561
517
 
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
- )
518
+ raise errors.APIError("Unexpected response received", http_res)
570
519
 
571
520
  async def update_async(
572
521
  self,
@@ -645,31 +594,20 @@ class Tools(BaseSDK):
645
594
 
646
595
  response_data: Any = None
647
596
  if utils.match_response(http_res, "200", "application/json"):
648
- return utils.unmarshal_json(http_res.text, models.ToolResponse)
597
+ return utils.unmarshal_json_response(models.ToolResponse, http_res)
649
598
  if utils.match_response(http_res, "422", "application/json"):
650
- response_data = utils.unmarshal_json(
651
- http_res.text, models.HTTPValidationErrorData
599
+ response_data = utils.unmarshal_json_response(
600
+ errors.HTTPValidationErrorData, http_res
652
601
  )
653
- raise models.HTTPValidationError(data=response_data)
602
+ raise errors.HTTPValidationError(response_data, http_res)
654
603
  if utils.match_response(http_res, "4XX", "*"):
655
604
  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
- )
605
+ raise errors.APIError("API error occurred", http_res, http_res_text)
659
606
  if utils.match_response(http_res, "5XX", "*"):
660
607
  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
- )
608
+ raise errors.APIError("API error occurred", http_res, http_res_text)
664
609
 
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
- )
610
+ raise errors.APIError("Unexpected response received", http_res)
673
611
 
674
612
  def get_by_name(
675
613
  self,
@@ -745,31 +683,20 @@ class Tools(BaseSDK):
745
683
 
746
684
  response_data: Any = None
747
685
  if utils.match_response(http_res, "200", "application/json"):
748
- return utils.unmarshal_json(http_res.text, models.ToolDetailResponse)
686
+ return utils.unmarshal_json_response(models.ToolDetailResponse, http_res)
749
687
  if utils.match_response(http_res, "422", "application/json"):
750
- response_data = utils.unmarshal_json(
751
- http_res.text, models.HTTPValidationErrorData
688
+ response_data = utils.unmarshal_json_response(
689
+ errors.HTTPValidationErrorData, http_res
752
690
  )
753
- raise models.HTTPValidationError(data=response_data)
691
+ raise errors.HTTPValidationError(response_data, http_res)
754
692
  if utils.match_response(http_res, "4XX", "*"):
755
693
  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
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
695
  if utils.match_response(http_res, "5XX", "*"):
760
696
  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
- )
697
+ raise errors.APIError("API error occurred", http_res, http_res_text)
764
698
 
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
- )
699
+ raise errors.APIError("Unexpected response received", http_res)
773
700
 
774
701
  async def get_by_name_async(
775
702
  self,
@@ -845,31 +772,20 @@ class Tools(BaseSDK):
845
772
 
846
773
  response_data: Any = None
847
774
  if utils.match_response(http_res, "200", "application/json"):
848
- return utils.unmarshal_json(http_res.text, models.ToolDetailResponse)
775
+ return utils.unmarshal_json_response(models.ToolDetailResponse, http_res)
849
776
  if utils.match_response(http_res, "422", "application/json"):
850
- response_data = utils.unmarshal_json(
851
- http_res.text, models.HTTPValidationErrorData
777
+ response_data = utils.unmarshal_json_response(
778
+ errors.HTTPValidationErrorData, http_res
852
779
  )
853
- raise models.HTTPValidationError(data=response_data)
780
+ raise errors.HTTPValidationError(response_data, http_res)
854
781
  if utils.match_response(http_res, "4XX", "*"):
855
782
  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
- )
783
+ raise errors.APIError("API error occurred", http_res, http_res_text)
859
784
  if utils.match_response(http_res, "5XX", "*"):
860
785
  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
- )
786
+ raise errors.APIError("API error occurred", http_res, http_res_text)
864
787
 
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
- )
788
+ raise errors.APIError("Unexpected response received", http_res)
873
789
 
874
790
  def delete(
875
791
  self,
@@ -948,31 +864,20 @@ class Tools(BaseSDK):
948
864
 
949
865
  response_data: Any = None
950
866
  if utils.match_response(http_res, "200", "application/json"):
951
- return utils.unmarshal_json(http_res.text, Any)
867
+ return utils.unmarshal_json_response(Any, http_res)
952
868
  if utils.match_response(http_res, "422", "application/json"):
953
- response_data = utils.unmarshal_json(
954
- http_res.text, models.HTTPValidationErrorData
869
+ response_data = utils.unmarshal_json_response(
870
+ errors.HTTPValidationErrorData, http_res
955
871
  )
956
- raise models.HTTPValidationError(data=response_data)
872
+ raise errors.HTTPValidationError(response_data, http_res)
957
873
  if utils.match_response(http_res, "4XX", "*"):
958
874
  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
- )
875
+ raise errors.APIError("API error occurred", http_res, http_res_text)
962
876
  if utils.match_response(http_res, "5XX", "*"):
963
877
  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
- )
878
+ raise errors.APIError("API error occurred", http_res, http_res_text)
967
879
 
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
- )
880
+ raise errors.APIError("Unexpected response received", http_res)
976
881
 
977
882
  async def delete_async(
978
883
  self,
@@ -1051,28 +956,17 @@ class Tools(BaseSDK):
1051
956
 
1052
957
  response_data: Any = None
1053
958
  if utils.match_response(http_res, "200", "application/json"):
1054
- return utils.unmarshal_json(http_res.text, Any)
959
+ return utils.unmarshal_json_response(Any, http_res)
1055
960
  if utils.match_response(http_res, "422", "application/json"):
1056
- response_data = utils.unmarshal_json(
1057
- http_res.text, models.HTTPValidationErrorData
961
+ response_data = utils.unmarshal_json_response(
962
+ errors.HTTPValidationErrorData, http_res
1058
963
  )
1059
- raise models.HTTPValidationError(data=response_data)
964
+ raise errors.HTTPValidationError(response_data, http_res)
1060
965
  if utils.match_response(http_res, "4XX", "*"):
1061
966
  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
- )
967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1065
968
  if utils.match_response(http_res, "5XX", "*"):
1066
969
  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
- )
970
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1070
971
 
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
- )
972
+ 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
@@ -81,33 +81,22 @@ class Transcript(BaseSDK):
81
81
 
82
82
  response_data: Any = None
83
83
  if utils.match_response(http_res, "200", "application/json"):
84
- return utils.unmarshal_json(
85
- http_res.text, models.SessionTranscriptionResponse
84
+ return utils.unmarshal_json_response(
85
+ models.SessionTranscriptionResponse, http_res
86
86
  )
87
87
  if utils.match_response(http_res, "422", "application/json"):
88
- response_data = utils.unmarshal_json(
89
- http_res.text, models.HTTPValidationErrorData
88
+ response_data = utils.unmarshal_json_response(
89
+ errors.HTTPValidationErrorData, http_res
90
90
  )
91
- raise models.HTTPValidationError(data=response_data)
91
+ raise errors.HTTPValidationError(response_data, http_res)
92
92
  if utils.match_response(http_res, "4XX", "*"):
93
93
  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
- )
94
+ raise errors.APIError("API error occurred", http_res, http_res_text)
97
95
  if utils.match_response(http_res, "5XX", "*"):
98
96
  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
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
98
 
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
- )
99
+ raise errors.APIError("Unexpected response received", http_res)
111
100
 
112
101
  async def get_by_id_async(
113
102
  self,
@@ -181,30 +170,19 @@ class Transcript(BaseSDK):
181
170
 
182
171
  response_data: Any = None
183
172
  if utils.match_response(http_res, "200", "application/json"):
184
- return utils.unmarshal_json(
185
- http_res.text, models.SessionTranscriptionResponse
173
+ return utils.unmarshal_json_response(
174
+ models.SessionTranscriptionResponse, http_res
186
175
  )
187
176
  if utils.match_response(http_res, "422", "application/json"):
188
- response_data = utils.unmarshal_json(
189
- http_res.text, models.HTTPValidationErrorData
177
+ response_data = utils.unmarshal_json_response(
178
+ errors.HTTPValidationErrorData, http_res
190
179
  )
191
- raise models.HTTPValidationError(data=response_data)
180
+ raise errors.HTTPValidationError(response_data, http_res)
192
181
  if utils.match_response(http_res, "4XX", "*"):
193
182
  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
- )
183
+ raise errors.APIError("API error occurred", http_res, http_res_text)
197
184
  if utils.match_response(http_res, "5XX", "*"):
198
185
  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
- )
186
+ raise errors.APIError("API error occurred", http_res, http_res_text)
202
187
 
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
- )
188
+ raise errors.APIError("Unexpected response received", http_res)