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
@@ -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, List, Mapping, Optional
9
10
 
10
11
 
@@ -107,31 +108,20 @@ class Conversations(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(http_res.text, models.ListResponseConversation)
111
+ return unmarshal_json_response(models.ListResponseConversation, http_res)
111
112
  if utils.match_response(http_res, "422", "application/json"):
112
- response_data = utils.unmarshal_json(
113
- http_res.text, models.HTTPValidationErrorData
113
+ response_data = unmarshal_json_response(
114
+ errors.HTTPValidationErrorData, http_res
114
115
  )
115
- raise models.HTTPValidationError(data=response_data)
116
+ raise errors.HTTPValidationError(response_data, http_res)
116
117
  if utils.match_response(http_res, "4XX", "*"):
117
118
  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
- )
119
+ raise errors.APIError("API error occurred", http_res, http_res_text)
121
120
  if utils.match_response(http_res, "5XX", "*"):
122
121
  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
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
126
123
 
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
- )
124
+ raise errors.APIError("Unexpected response received", http_res)
135
125
 
136
126
  async def list_async(
137
127
  self,
@@ -229,28 +219,17 @@ class Conversations(BaseSDK):
229
219
 
230
220
  response_data: Any = None
231
221
  if utils.match_response(http_res, "200", "application/json"):
232
- return utils.unmarshal_json(http_res.text, models.ListResponseConversation)
222
+ return unmarshal_json_response(models.ListResponseConversation, http_res)
233
223
  if utils.match_response(http_res, "422", "application/json"):
234
- response_data = utils.unmarshal_json(
235
- http_res.text, models.HTTPValidationErrorData
224
+ response_data = unmarshal_json_response(
225
+ errors.HTTPValidationErrorData, http_res
236
226
  )
237
- raise models.HTTPValidationError(data=response_data)
227
+ raise errors.HTTPValidationError(response_data, http_res)
238
228
  if utils.match_response(http_res, "4XX", "*"):
239
229
  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
- )
230
+ raise errors.APIError("API error occurred", http_res, http_res_text)
243
231
  if utils.match_response(http_res, "5XX", "*"):
244
232
  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
- )
233
+ raise errors.APIError("API error occurred", http_res, http_res_text)
248
234
 
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
- )
235
+ 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 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,33 +110,22 @@ class CustomMessages(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(
113
- http_res.text, models.ListResponseCustomMessageResponse
113
+ return unmarshal_json_response(
114
+ models.ListResponseCustomMessageResponse, http_res
114
115
  )
115
116
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
117
+ response_data = unmarshal_json_response(
118
+ errors.HTTPValidationErrorData, http_res
118
119
  )
119
- raise models.HTTPValidationError(data=response_data)
120
+ raise errors.HTTPValidationError(response_data, http_res)
120
121
  if utils.match_response(http_res, "4XX", "*"):
121
122
  http_res_text = utils.stream_to_text(http_res)
122
- raise models.APIError(
123
- "API error occurred", http_res.status_code, http_res_text, http_res
124
- )
123
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
124
  if utils.match_response(http_res, "5XX", "*"):
126
125
  http_res_text = utils.stream_to_text(http_res)
127
- raise models.APIError(
128
- "API error occurred", http_res.status_code, http_res_text, http_res
129
- )
126
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
127
 
131
- content_type = http_res.headers.get("Content-Type")
132
- http_res_text = utils.stream_to_text(http_res)
133
- raise models.APIError(
134
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
135
- http_res.status_code,
136
- http_res_text,
137
- http_res,
138
- )
128
+ raise errors.APIError("Unexpected response received", http_res)
139
129
 
140
130
  async def list_async(
141
131
  self,
@@ -235,33 +225,22 @@ class CustomMessages(BaseSDK):
235
225
 
236
226
  response_data: Any = None
237
227
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseCustomMessageResponse
228
+ return unmarshal_json_response(
229
+ models.ListResponseCustomMessageResponse, http_res
240
230
  )
241
231
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
232
+ response_data = unmarshal_json_response(
233
+ errors.HTTPValidationErrorData, http_res
244
234
  )
245
- raise models.HTTPValidationError(data=response_data)
235
+ raise errors.HTTPValidationError(response_data, http_res)
246
236
  if utils.match_response(http_res, "4XX", "*"):
247
237
  http_res_text = await utils.stream_to_text_async(http_res)
248
- raise models.APIError(
249
- "API error occurred", http_res.status_code, http_res_text, http_res
250
- )
238
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
239
  if utils.match_response(http_res, "5XX", "*"):
252
240
  http_res_text = await utils.stream_to_text_async(http_res)
253
- raise models.APIError(
254
- "API error occurred", http_res.status_code, http_res_text, http_res
255
- )
241
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
242
 
257
- content_type = http_res.headers.get("Content-Type")
258
- http_res_text = await utils.stream_to_text_async(http_res)
259
- raise models.APIError(
260
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
261
- http_res.status_code,
262
- http_res_text,
263
- http_res,
264
- )
243
+ raise errors.APIError("Unexpected response received", http_res)
265
244
 
266
245
  def create(
267
246
  self,
@@ -343,31 +322,20 @@ class CustomMessages(BaseSDK):
343
322
 
344
323
  response_data: Any = None
345
324
  if utils.match_response(http_res, "200", "application/json"):
346
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
325
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
347
326
  if utils.match_response(http_res, "422", "application/json"):
348
- response_data = utils.unmarshal_json(
349
- http_res.text, models.HTTPValidationErrorData
327
+ response_data = unmarshal_json_response(
328
+ errors.HTTPValidationErrorData, http_res
350
329
  )
351
- raise models.HTTPValidationError(data=response_data)
330
+ raise errors.HTTPValidationError(response_data, http_res)
352
331
  if utils.match_response(http_res, "4XX", "*"):
353
332
  http_res_text = utils.stream_to_text(http_res)
354
- raise models.APIError(
355
- "API error occurred", http_res.status_code, http_res_text, http_res
356
- )
333
+ raise errors.APIError("API error occurred", http_res, http_res_text)
357
334
  if utils.match_response(http_res, "5XX", "*"):
358
335
  http_res_text = utils.stream_to_text(http_res)
359
- raise models.APIError(
360
- "API error occurred", http_res.status_code, http_res_text, http_res
361
- )
336
+ raise errors.APIError("API error occurred", http_res, http_res_text)
362
337
 
363
- content_type = http_res.headers.get("Content-Type")
364
- http_res_text = utils.stream_to_text(http_res)
365
- raise models.APIError(
366
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
367
- http_res.status_code,
368
- http_res_text,
369
- http_res,
370
- )
338
+ raise errors.APIError("Unexpected response received", http_res)
371
339
 
372
340
  async def create_async(
373
341
  self,
@@ -449,31 +417,20 @@ class CustomMessages(BaseSDK):
449
417
 
450
418
  response_data: Any = None
451
419
  if utils.match_response(http_res, "200", "application/json"):
452
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
420
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
453
421
  if utils.match_response(http_res, "422", "application/json"):
454
- response_data = utils.unmarshal_json(
455
- http_res.text, models.HTTPValidationErrorData
422
+ response_data = unmarshal_json_response(
423
+ errors.HTTPValidationErrorData, http_res
456
424
  )
457
- raise models.HTTPValidationError(data=response_data)
425
+ raise errors.HTTPValidationError(response_data, http_res)
458
426
  if utils.match_response(http_res, "4XX", "*"):
459
427
  http_res_text = await utils.stream_to_text_async(http_res)
460
- raise models.APIError(
461
- "API error occurred", http_res.status_code, http_res_text, http_res
462
- )
428
+ raise errors.APIError("API error occurred", http_res, http_res_text)
463
429
  if utils.match_response(http_res, "5XX", "*"):
464
430
  http_res_text = await utils.stream_to_text_async(http_res)
465
- raise models.APIError(
466
- "API error occurred", http_res.status_code, http_res_text, http_res
467
- )
431
+ raise errors.APIError("API error occurred", http_res, http_res_text)
468
432
 
469
- content_type = http_res.headers.get("Content-Type")
470
- http_res_text = await utils.stream_to_text_async(http_res)
471
- raise models.APIError(
472
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
473
- http_res.status_code,
474
- http_res_text,
475
- http_res,
476
- )
433
+ raise errors.APIError("Unexpected response received", http_res)
477
434
 
478
435
  def update(
479
436
  self,
@@ -555,31 +512,20 @@ class CustomMessages(BaseSDK):
555
512
 
556
513
  response_data: Any = None
557
514
  if utils.match_response(http_res, "200", "application/json"):
558
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
515
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
559
516
  if utils.match_response(http_res, "422", "application/json"):
560
- response_data = utils.unmarshal_json(
561
- http_res.text, models.HTTPValidationErrorData
517
+ response_data = unmarshal_json_response(
518
+ errors.HTTPValidationErrorData, http_res
562
519
  )
563
- raise models.HTTPValidationError(data=response_data)
520
+ raise errors.HTTPValidationError(response_data, http_res)
564
521
  if utils.match_response(http_res, "4XX", "*"):
565
522
  http_res_text = utils.stream_to_text(http_res)
566
- raise models.APIError(
567
- "API error occurred", http_res.status_code, http_res_text, http_res
568
- )
523
+ raise errors.APIError("API error occurred", http_res, http_res_text)
569
524
  if utils.match_response(http_res, "5XX", "*"):
570
525
  http_res_text = utils.stream_to_text(http_res)
571
- raise models.APIError(
572
- "API error occurred", http_res.status_code, http_res_text, http_res
573
- )
526
+ raise errors.APIError("API error occurred", http_res, http_res_text)
574
527
 
575
- content_type = http_res.headers.get("Content-Type")
576
- http_res_text = utils.stream_to_text(http_res)
577
- raise models.APIError(
578
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
579
- http_res.status_code,
580
- http_res_text,
581
- http_res,
582
- )
528
+ raise errors.APIError("Unexpected response received", http_res)
583
529
 
584
530
  async def update_async(
585
531
  self,
@@ -661,31 +607,20 @@ class CustomMessages(BaseSDK):
661
607
 
662
608
  response_data: Any = None
663
609
  if utils.match_response(http_res, "200", "application/json"):
664
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
610
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
665
611
  if utils.match_response(http_res, "422", "application/json"):
666
- response_data = utils.unmarshal_json(
667
- http_res.text, models.HTTPValidationErrorData
612
+ response_data = unmarshal_json_response(
613
+ errors.HTTPValidationErrorData, http_res
668
614
  )
669
- raise models.HTTPValidationError(data=response_data)
615
+ raise errors.HTTPValidationError(response_data, http_res)
670
616
  if utils.match_response(http_res, "4XX", "*"):
671
617
  http_res_text = await utils.stream_to_text_async(http_res)
672
- raise models.APIError(
673
- "API error occurred", http_res.status_code, http_res_text, http_res
674
- )
618
+ raise errors.APIError("API error occurred", http_res, http_res_text)
675
619
  if utils.match_response(http_res, "5XX", "*"):
676
620
  http_res_text = await utils.stream_to_text_async(http_res)
677
- raise models.APIError(
678
- "API error occurred", http_res.status_code, http_res_text, http_res
679
- )
621
+ raise errors.APIError("API error occurred", http_res, http_res_text)
680
622
 
681
- content_type = http_res.headers.get("Content-Type")
682
- http_res_text = await utils.stream_to_text_async(http_res)
683
- raise models.APIError(
684
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
685
- http_res.status_code,
686
- http_res_text,
687
- http_res,
688
- )
623
+ raise errors.APIError("Unexpected response received", http_res)
689
624
 
690
625
  def get_by_id(
691
626
  self,
@@ -761,31 +696,20 @@ class CustomMessages(BaseSDK):
761
696
 
762
697
  response_data: Any = None
763
698
  if utils.match_response(http_res, "200", "application/json"):
764
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
699
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
765
700
  if utils.match_response(http_res, "422", "application/json"):
766
- response_data = utils.unmarshal_json(
767
- http_res.text, models.HTTPValidationErrorData
701
+ response_data = unmarshal_json_response(
702
+ errors.HTTPValidationErrorData, http_res
768
703
  )
769
- raise models.HTTPValidationError(data=response_data)
704
+ raise errors.HTTPValidationError(response_data, http_res)
770
705
  if utils.match_response(http_res, "4XX", "*"):
771
706
  http_res_text = utils.stream_to_text(http_res)
772
- raise models.APIError(
773
- "API error occurred", http_res.status_code, http_res_text, http_res
774
- )
707
+ raise errors.APIError("API error occurred", http_res, http_res_text)
775
708
  if utils.match_response(http_res, "5XX", "*"):
776
709
  http_res_text = utils.stream_to_text(http_res)
777
- raise models.APIError(
778
- "API error occurred", http_res.status_code, http_res_text, http_res
779
- )
710
+ raise errors.APIError("API error occurred", http_res, http_res_text)
780
711
 
781
- content_type = http_res.headers.get("Content-Type")
782
- http_res_text = utils.stream_to_text(http_res)
783
- raise models.APIError(
784
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
785
- http_res.status_code,
786
- http_res_text,
787
- http_res,
788
- )
712
+ raise errors.APIError("Unexpected response received", http_res)
789
713
 
790
714
  async def get_by_id_async(
791
715
  self,
@@ -861,31 +785,20 @@ class CustomMessages(BaseSDK):
861
785
 
862
786
  response_data: Any = None
863
787
  if utils.match_response(http_res, "200", "application/json"):
864
- return utils.unmarshal_json(http_res.text, models.CustomMessageResponse)
788
+ return unmarshal_json_response(models.CustomMessageResponse, http_res)
865
789
  if utils.match_response(http_res, "422", "application/json"):
866
- response_data = utils.unmarshal_json(
867
- http_res.text, models.HTTPValidationErrorData
790
+ response_data = unmarshal_json_response(
791
+ errors.HTTPValidationErrorData, http_res
868
792
  )
869
- raise models.HTTPValidationError(data=response_data)
793
+ raise errors.HTTPValidationError(response_data, http_res)
870
794
  if utils.match_response(http_res, "4XX", "*"):
871
795
  http_res_text = await utils.stream_to_text_async(http_res)
872
- raise models.APIError(
873
- "API error occurred", http_res.status_code, http_res_text, http_res
874
- )
796
+ raise errors.APIError("API error occurred", http_res, http_res_text)
875
797
  if utils.match_response(http_res, "5XX", "*"):
876
798
  http_res_text = await utils.stream_to_text_async(http_res)
877
- raise models.APIError(
878
- "API error occurred", http_res.status_code, http_res_text, http_res
879
- )
799
+ raise errors.APIError("API error occurred", http_res, http_res_text)
880
800
 
881
- content_type = http_res.headers.get("Content-Type")
882
- http_res_text = await utils.stream_to_text_async(http_res)
883
- raise models.APIError(
884
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
885
- http_res.status_code,
886
- http_res_text,
887
- http_res,
888
- )
801
+ raise errors.APIError("Unexpected response received", http_res)
889
802
 
890
803
  def delete(
891
804
  self,
@@ -964,31 +877,20 @@ class CustomMessages(BaseSDK):
964
877
 
965
878
  response_data: Any = None
966
879
  if utils.match_response(http_res, "200", "application/json"):
967
- return utils.unmarshal_json(http_res.text, Any)
880
+ return unmarshal_json_response(Any, http_res)
968
881
  if utils.match_response(http_res, "422", "application/json"):
969
- response_data = utils.unmarshal_json(
970
- http_res.text, models.HTTPValidationErrorData
882
+ response_data = unmarshal_json_response(
883
+ errors.HTTPValidationErrorData, http_res
971
884
  )
972
- raise models.HTTPValidationError(data=response_data)
885
+ raise errors.HTTPValidationError(response_data, http_res)
973
886
  if utils.match_response(http_res, "4XX", "*"):
974
887
  http_res_text = utils.stream_to_text(http_res)
975
- raise models.APIError(
976
- "API error occurred", http_res.status_code, http_res_text, http_res
977
- )
888
+ raise errors.APIError("API error occurred", http_res, http_res_text)
978
889
  if utils.match_response(http_res, "5XX", "*"):
979
890
  http_res_text = utils.stream_to_text(http_res)
980
- raise models.APIError(
981
- "API error occurred", http_res.status_code, http_res_text, http_res
982
- )
891
+ raise errors.APIError("API error occurred", http_res, http_res_text)
983
892
 
984
- content_type = http_res.headers.get("Content-Type")
985
- http_res_text = utils.stream_to_text(http_res)
986
- raise models.APIError(
987
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
988
- http_res.status_code,
989
- http_res_text,
990
- http_res,
991
- )
893
+ raise errors.APIError("Unexpected response received", http_res)
992
894
 
993
895
  async def delete_async(
994
896
  self,
@@ -1067,28 +969,17 @@ class CustomMessages(BaseSDK):
1067
969
 
1068
970
  response_data: Any = None
1069
971
  if utils.match_response(http_res, "200", "application/json"):
1070
- return utils.unmarshal_json(http_res.text, Any)
972
+ return unmarshal_json_response(Any, http_res)
1071
973
  if utils.match_response(http_res, "422", "application/json"):
1072
- response_data = utils.unmarshal_json(
1073
- http_res.text, models.HTTPValidationErrorData
974
+ response_data = unmarshal_json_response(
975
+ errors.HTTPValidationErrorData, http_res
1074
976
  )
1075
- raise models.HTTPValidationError(data=response_data)
977
+ raise errors.HTTPValidationError(response_data, http_res)
1076
978
  if utils.match_response(http_res, "4XX", "*"):
1077
979
  http_res_text = await utils.stream_to_text_async(http_res)
1078
- raise models.APIError(
1079
- "API error occurred", http_res.status_code, http_res_text, http_res
1080
- )
980
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1081
981
  if utils.match_response(http_res, "5XX", "*"):
1082
982
  http_res_text = await utils.stream_to_text_async(http_res)
1083
- raise models.APIError(
1084
- "API error occurred", http_res.status_code, http_res_text, http_res
1085
- )
983
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1086
984
 
1087
- content_type = http_res.headers.get("Content-Type")
1088
- http_res_text = await utils.stream_to_text_async(http_res)
1089
- raise models.APIError(
1090
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1091
- http_res.status_code,
1092
- http_res_text,
1093
- http_res,
1094
- )
985
+ raise errors.APIError("Unexpected response received", http_res)