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/takeouts.py CHANGED
@@ -2,10 +2,11 @@
2
2
 
3
3
  from .basesdk import BaseSDK
4
4
  import httpx
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.types import OptionalNullable, UNSET
8
8
  from syllable_sdk.utils import get_security_from_env
9
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
9
10
  from typing import Any, Mapping, Optional
10
11
 
11
12
 
@@ -74,26 +75,15 @@ class Takeouts(BaseSDK):
74
75
  )
75
76
 
76
77
  if utils.match_response(http_res, "200", "application/json"):
77
- return utils.unmarshal_json(http_res.text, models.CreateTakeoutResponse)
78
+ return unmarshal_json_response(models.CreateTakeoutResponse, http_res)
78
79
  if utils.match_response(http_res, "4XX", "*"):
79
80
  http_res_text = utils.stream_to_text(http_res)
80
- raise models.APIError(
81
- "API error occurred", http_res.status_code, http_res_text, http_res
82
- )
81
+ raise errors.APIError("API error occurred", http_res, http_res_text)
83
82
  if utils.match_response(http_res, "5XX", "*"):
84
83
  http_res_text = utils.stream_to_text(http_res)
85
- raise models.APIError(
86
- "API error occurred", http_res.status_code, http_res_text, http_res
87
- )
84
+ raise errors.APIError("API error occurred", http_res, http_res_text)
88
85
 
89
- content_type = http_res.headers.get("Content-Type")
90
- http_res_text = utils.stream_to_text(http_res)
91
- raise models.APIError(
92
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
93
- http_res.status_code,
94
- http_res_text,
95
- http_res,
96
- )
86
+ raise errors.APIError("Unexpected response received", http_res)
97
87
 
98
88
  async def create_async(
99
89
  self,
@@ -159,26 +149,15 @@ class Takeouts(BaseSDK):
159
149
  )
160
150
 
161
151
  if utils.match_response(http_res, "200", "application/json"):
162
- return utils.unmarshal_json(http_res.text, models.CreateTakeoutResponse)
152
+ return unmarshal_json_response(models.CreateTakeoutResponse, http_res)
163
153
  if utils.match_response(http_res, "4XX", "*"):
164
154
  http_res_text = await utils.stream_to_text_async(http_res)
165
- raise models.APIError(
166
- "API error occurred", http_res.status_code, http_res_text, http_res
167
- )
155
+ raise errors.APIError("API error occurred", http_res, http_res_text)
168
156
  if utils.match_response(http_res, "5XX", "*"):
169
157
  http_res_text = await utils.stream_to_text_async(http_res)
170
- raise models.APIError(
171
- "API error occurred", http_res.status_code, http_res_text, http_res
172
- )
158
+ raise errors.APIError("API error occurred", http_res, http_res_text)
173
159
 
174
- content_type = http_res.headers.get("Content-Type")
175
- http_res_text = await utils.stream_to_text_async(http_res)
176
- raise models.APIError(
177
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
178
- http_res.status_code,
179
- http_res_text,
180
- http_res,
181
- )
160
+ raise errors.APIError("Unexpected response received", http_res)
182
161
 
183
162
  def takeouts_get_by_job_id(
184
163
  self,
@@ -252,31 +231,20 @@ class Takeouts(BaseSDK):
252
231
 
253
232
  response_data: Any = None
254
233
  if utils.match_response(http_res, "200", "application/json"):
255
- return utils.unmarshal_json(http_res.text, models.TakeoutStatusResponse)
234
+ return unmarshal_json_response(models.TakeoutStatusResponse, http_res)
256
235
  if utils.match_response(http_res, "422", "application/json"):
257
- response_data = utils.unmarshal_json(
258
- http_res.text, models.HTTPValidationErrorData
236
+ response_data = unmarshal_json_response(
237
+ errors.HTTPValidationErrorData, http_res
259
238
  )
260
- raise models.HTTPValidationError(data=response_data)
239
+ raise errors.HTTPValidationError(response_data, http_res)
261
240
  if utils.match_response(http_res, "4XX", "*"):
262
241
  http_res_text = utils.stream_to_text(http_res)
263
- raise models.APIError(
264
- "API error occurred", http_res.status_code, http_res_text, http_res
265
- )
242
+ raise errors.APIError("API error occurred", http_res, http_res_text)
266
243
  if utils.match_response(http_res, "5XX", "*"):
267
244
  http_res_text = utils.stream_to_text(http_res)
268
- raise models.APIError(
269
- "API error occurred", http_res.status_code, http_res_text, http_res
270
- )
245
+ raise errors.APIError("API error occurred", http_res, http_res_text)
271
246
 
272
- content_type = http_res.headers.get("Content-Type")
273
- http_res_text = utils.stream_to_text(http_res)
274
- raise models.APIError(
275
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
276
- http_res.status_code,
277
- http_res_text,
278
- http_res,
279
- )
247
+ raise errors.APIError("Unexpected response received", http_res)
280
248
 
281
249
  async def takeouts_get_by_job_id_async(
282
250
  self,
@@ -350,31 +318,20 @@ class Takeouts(BaseSDK):
350
318
 
351
319
  response_data: Any = None
352
320
  if utils.match_response(http_res, "200", "application/json"):
353
- return utils.unmarshal_json(http_res.text, models.TakeoutStatusResponse)
321
+ return unmarshal_json_response(models.TakeoutStatusResponse, http_res)
354
322
  if utils.match_response(http_res, "422", "application/json"):
355
- response_data = utils.unmarshal_json(
356
- http_res.text, models.HTTPValidationErrorData
323
+ response_data = unmarshal_json_response(
324
+ errors.HTTPValidationErrorData, http_res
357
325
  )
358
- raise models.HTTPValidationError(data=response_data)
326
+ raise errors.HTTPValidationError(response_data, http_res)
359
327
  if utils.match_response(http_res, "4XX", "*"):
360
328
  http_res_text = await utils.stream_to_text_async(http_res)
361
- raise models.APIError(
362
- "API error occurred", http_res.status_code, http_res_text, http_res
363
- )
329
+ raise errors.APIError("API error occurred", http_res, http_res_text)
364
330
  if utils.match_response(http_res, "5XX", "*"):
365
331
  http_res_text = await utils.stream_to_text_async(http_res)
366
- raise models.APIError(
367
- "API error occurred", http_res.status_code, http_res_text, http_res
368
- )
332
+ raise errors.APIError("API error occurred", http_res, http_res_text)
369
333
 
370
- content_type = http_res.headers.get("Content-Type")
371
- http_res_text = await utils.stream_to_text_async(http_res)
372
- raise models.APIError(
373
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
374
- http_res.status_code,
375
- http_res_text,
376
- http_res,
377
- )
334
+ raise errors.APIError("Unexpected response received", http_res)
378
335
 
379
336
  def takeouts_get_file(
380
337
  self,
@@ -455,29 +412,19 @@ class Takeouts(BaseSDK):
455
412
  return http_res
456
413
  if utils.match_response(http_res, "422", "application/json"):
457
414
  http_res_text = utils.stream_to_text(http_res)
458
- response_data = utils.unmarshal_json(
459
- http_res_text, models.HTTPValidationErrorData
415
+ response_data = unmarshal_json_response(
416
+ errors.HTTPValidationErrorData, http_res, http_res_text
460
417
  )
461
- raise models.HTTPValidationError(data=response_data)
418
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
462
419
  if utils.match_response(http_res, "4XX", "*"):
463
420
  http_res_text = utils.stream_to_text(http_res)
464
- raise models.APIError(
465
- "API error occurred", http_res.status_code, http_res_text, http_res
466
- )
421
+ raise errors.APIError("API error occurred", http_res, http_res_text)
467
422
  if utils.match_response(http_res, "5XX", "*"):
468
423
  http_res_text = utils.stream_to_text(http_res)
469
- raise models.APIError(
470
- "API error occurred", http_res.status_code, http_res_text, http_res
471
- )
424
+ raise errors.APIError("API error occurred", http_res, http_res_text)
472
425
 
473
- content_type = http_res.headers.get("Content-Type")
474
426
  http_res_text = utils.stream_to_text(http_res)
475
- raise models.APIError(
476
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
477
- http_res.status_code,
478
- http_res_text,
479
- http_res,
480
- )
427
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
481
428
 
482
429
  async def takeouts_get_file_async(
483
430
  self,
@@ -558,26 +505,16 @@ class Takeouts(BaseSDK):
558
505
  return http_res
559
506
  if utils.match_response(http_res, "422", "application/json"):
560
507
  http_res_text = await utils.stream_to_text_async(http_res)
561
- response_data = utils.unmarshal_json(
562
- http_res_text, models.HTTPValidationErrorData
508
+ response_data = unmarshal_json_response(
509
+ errors.HTTPValidationErrorData, http_res, http_res_text
563
510
  )
564
- raise models.HTTPValidationError(data=response_data)
511
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
565
512
  if utils.match_response(http_res, "4XX", "*"):
566
513
  http_res_text = await utils.stream_to_text_async(http_res)
567
- raise models.APIError(
568
- "API error occurred", http_res.status_code, http_res_text, http_res
569
- )
514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
570
515
  if utils.match_response(http_res, "5XX", "*"):
571
516
  http_res_text = await utils.stream_to_text_async(http_res)
572
- raise models.APIError(
573
- "API error occurred", http_res.status_code, http_res_text, http_res
574
- )
517
+ raise errors.APIError("API error occurred", http_res, http_res_text)
575
518
 
576
- content_type = http_res.headers.get("Content-Type")
577
519
  http_res_text = await utils.stream_to_text_async(http_res)
578
- raise models.APIError(
579
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
580
- http_res.status_code,
581
- http_res_text,
582
- http_res,
583
- )
520
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
syllable_sdk/targets.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 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
9
10
 
10
11
 
@@ -109,33 +110,20 @@ class Targets(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.ListResponseAvailableTarget
114
- )
113
+ return unmarshal_json_response(models.ListResponseAvailableTarget, http_res)
115
114
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
115
+ response_data = unmarshal_json_response(
116
+ errors.HTTPValidationErrorData, http_res
118
117
  )
119
- raise models.HTTPValidationError(data=response_data)
118
+ raise errors.HTTPValidationError(response_data, http_res)
120
119
  if utils.match_response(http_res, "4XX", "*"):
121
120
  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
- )
121
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
122
  if utils.match_response(http_res, "5XX", "*"):
126
123
  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
- )
124
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
125
 
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
- )
126
+ raise errors.APIError("Unexpected response received", http_res)
139
127
 
140
128
  async def available_targets_async(
141
129
  self,
@@ -235,33 +223,20 @@ class Targets(BaseSDK):
235
223
 
236
224
  response_data: Any = None
237
225
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseAvailableTarget
240
- )
226
+ return unmarshal_json_response(models.ListResponseAvailableTarget, http_res)
241
227
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
228
+ response_data = unmarshal_json_response(
229
+ errors.HTTPValidationErrorData, http_res
244
230
  )
245
- raise models.HTTPValidationError(data=response_data)
231
+ raise errors.HTTPValidationError(response_data, http_res)
246
232
  if utils.match_response(http_res, "4XX", "*"):
247
233
  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
- )
234
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
235
  if utils.match_response(http_res, "5XX", "*"):
252
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
238
 
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
- )
239
+ raise errors.APIError("Unexpected response received", http_res)
265
240
 
266
241
  def list(
267
242
  self,
@@ -359,33 +334,22 @@ class Targets(BaseSDK):
359
334
 
360
335
  response_data: Any = None
361
336
  if utils.match_response(http_res, "200", "application/json"):
362
- return utils.unmarshal_json(
363
- http_res.text, models.ListResponseChannelTargetResponse
337
+ return unmarshal_json_response(
338
+ models.ListResponseChannelTargetResponse, http_res
364
339
  )
365
340
  if utils.match_response(http_res, "422", "application/json"):
366
- response_data = utils.unmarshal_json(
367
- http_res.text, models.HTTPValidationErrorData
341
+ response_data = unmarshal_json_response(
342
+ errors.HTTPValidationErrorData, http_res
368
343
  )
369
- raise models.HTTPValidationError(data=response_data)
344
+ raise errors.HTTPValidationError(response_data, http_res)
370
345
  if utils.match_response(http_res, "4XX", "*"):
371
346
  http_res_text = utils.stream_to_text(http_res)
372
- raise models.APIError(
373
- "API error occurred", http_res.status_code, http_res_text, http_res
374
- )
347
+ raise errors.APIError("API error occurred", http_res, http_res_text)
375
348
  if utils.match_response(http_res, "5XX", "*"):
376
349
  http_res_text = utils.stream_to_text(http_res)
377
- raise models.APIError(
378
- "API error occurred", http_res.status_code, http_res_text, http_res
379
- )
350
+ raise errors.APIError("API error occurred", http_res, http_res_text)
380
351
 
381
- content_type = http_res.headers.get("Content-Type")
382
- http_res_text = utils.stream_to_text(http_res)
383
- raise models.APIError(
384
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
385
- http_res.status_code,
386
- http_res_text,
387
- http_res,
388
- )
352
+ raise errors.APIError("Unexpected response received", http_res)
389
353
 
390
354
  async def list_async(
391
355
  self,
@@ -483,33 +447,22 @@ class Targets(BaseSDK):
483
447
 
484
448
  response_data: Any = None
485
449
  if utils.match_response(http_res, "200", "application/json"):
486
- return utils.unmarshal_json(
487
- http_res.text, models.ListResponseChannelTargetResponse
450
+ return unmarshal_json_response(
451
+ models.ListResponseChannelTargetResponse, http_res
488
452
  )
489
453
  if utils.match_response(http_res, "422", "application/json"):
490
- response_data = utils.unmarshal_json(
491
- http_res.text, models.HTTPValidationErrorData
454
+ response_data = unmarshal_json_response(
455
+ errors.HTTPValidationErrorData, http_res
492
456
  )
493
- raise models.HTTPValidationError(data=response_data)
457
+ raise errors.HTTPValidationError(response_data, http_res)
494
458
  if utils.match_response(http_res, "4XX", "*"):
495
459
  http_res_text = await utils.stream_to_text_async(http_res)
496
- raise models.APIError(
497
- "API error occurred", http_res.status_code, http_res_text, http_res
498
- )
460
+ raise errors.APIError("API error occurred", http_res, http_res_text)
499
461
  if utils.match_response(http_res, "5XX", "*"):
500
462
  http_res_text = await utils.stream_to_text_async(http_res)
501
- raise models.APIError(
502
- "API error occurred", http_res.status_code, http_res_text, http_res
503
- )
463
+ raise errors.APIError("API error occurred", http_res, http_res_text)
504
464
 
505
- content_type = http_res.headers.get("Content-Type")
506
- http_res_text = await utils.stream_to_text_async(http_res)
507
- raise models.APIError(
508
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
509
- http_res.status_code,
510
- http_res_text,
511
- http_res,
512
- )
465
+ raise errors.APIError("Unexpected response received", http_res)
513
466
 
514
467
  def create(
515
468
  self,
@@ -598,31 +551,20 @@ class Targets(BaseSDK):
598
551
 
599
552
  response_data: Any = None
600
553
  if utils.match_response(http_res, "200", "application/json"):
601
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
554
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
602
555
  if utils.match_response(http_res, "422", "application/json"):
603
- response_data = utils.unmarshal_json(
604
- http_res.text, models.HTTPValidationErrorData
556
+ response_data = unmarshal_json_response(
557
+ errors.HTTPValidationErrorData, http_res
605
558
  )
606
- raise models.HTTPValidationError(data=response_data)
559
+ raise errors.HTTPValidationError(response_data, http_res)
607
560
  if utils.match_response(http_res, "4XX", "*"):
608
561
  http_res_text = utils.stream_to_text(http_res)
609
- raise models.APIError(
610
- "API error occurred", http_res.status_code, http_res_text, http_res
611
- )
562
+ raise errors.APIError("API error occurred", http_res, http_res_text)
612
563
  if utils.match_response(http_res, "5XX", "*"):
613
564
  http_res_text = utils.stream_to_text(http_res)
614
- raise models.APIError(
615
- "API error occurred", http_res.status_code, http_res_text, http_res
616
- )
565
+ raise errors.APIError("API error occurred", http_res, http_res_text)
617
566
 
618
- content_type = http_res.headers.get("Content-Type")
619
- http_res_text = utils.stream_to_text(http_res)
620
- raise models.APIError(
621
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
622
- http_res.status_code,
623
- http_res_text,
624
- http_res,
625
- )
567
+ raise errors.APIError("Unexpected response received", http_res)
626
568
 
627
569
  async def create_async(
628
570
  self,
@@ -711,31 +653,20 @@ class Targets(BaseSDK):
711
653
 
712
654
  response_data: Any = None
713
655
  if utils.match_response(http_res, "200", "application/json"):
714
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
656
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
715
657
  if utils.match_response(http_res, "422", "application/json"):
716
- response_data = utils.unmarshal_json(
717
- http_res.text, models.HTTPValidationErrorData
658
+ response_data = unmarshal_json_response(
659
+ errors.HTTPValidationErrorData, http_res
718
660
  )
719
- raise models.HTTPValidationError(data=response_data)
661
+ raise errors.HTTPValidationError(response_data, http_res)
720
662
  if utils.match_response(http_res, "4XX", "*"):
721
663
  http_res_text = await utils.stream_to_text_async(http_res)
722
- raise models.APIError(
723
- "API error occurred", http_res.status_code, http_res_text, http_res
724
- )
664
+ raise errors.APIError("API error occurred", http_res, http_res_text)
725
665
  if utils.match_response(http_res, "5XX", "*"):
726
666
  http_res_text = await utils.stream_to_text_async(http_res)
727
- raise models.APIError(
728
- "API error occurred", http_res.status_code, http_res_text, http_res
729
- )
667
+ raise errors.APIError("API error occurred", http_res, http_res_text)
730
668
 
731
- content_type = http_res.headers.get("Content-Type")
732
- http_res_text = await utils.stream_to_text_async(http_res)
733
- raise models.APIError(
734
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
735
- http_res.status_code,
736
- http_res_text,
737
- http_res,
738
- )
669
+ raise errors.APIError("Unexpected response received", http_res)
739
670
 
740
671
  def get_by_id(
741
672
  self,
@@ -812,31 +743,20 @@ class Targets(BaseSDK):
812
743
 
813
744
  response_data: Any = None
814
745
  if utils.match_response(http_res, "200", "application/json"):
815
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
746
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
816
747
  if utils.match_response(http_res, "422", "application/json"):
817
- response_data = utils.unmarshal_json(
818
- http_res.text, models.HTTPValidationErrorData
748
+ response_data = unmarshal_json_response(
749
+ errors.HTTPValidationErrorData, http_res
819
750
  )
820
- raise models.HTTPValidationError(data=response_data)
751
+ raise errors.HTTPValidationError(response_data, http_res)
821
752
  if utils.match_response(http_res, "4XX", "*"):
822
753
  http_res_text = utils.stream_to_text(http_res)
823
- raise models.APIError(
824
- "API error occurred", http_res.status_code, http_res_text, http_res
825
- )
754
+ raise errors.APIError("API error occurred", http_res, http_res_text)
826
755
  if utils.match_response(http_res, "5XX", "*"):
827
756
  http_res_text = utils.stream_to_text(http_res)
828
- raise models.APIError(
829
- "API error occurred", http_res.status_code, http_res_text, http_res
830
- )
757
+ raise errors.APIError("API error occurred", http_res, http_res_text)
831
758
 
832
- content_type = http_res.headers.get("Content-Type")
833
- http_res_text = utils.stream_to_text(http_res)
834
- raise models.APIError(
835
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
836
- http_res.status_code,
837
- http_res_text,
838
- http_res,
839
- )
759
+ raise errors.APIError("Unexpected response received", http_res)
840
760
 
841
761
  async def get_by_id_async(
842
762
  self,
@@ -913,31 +833,20 @@ class Targets(BaseSDK):
913
833
 
914
834
  response_data: Any = None
915
835
  if utils.match_response(http_res, "200", "application/json"):
916
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
836
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
917
837
  if utils.match_response(http_res, "422", "application/json"):
918
- response_data = utils.unmarshal_json(
919
- http_res.text, models.HTTPValidationErrorData
838
+ response_data = unmarshal_json_response(
839
+ errors.HTTPValidationErrorData, http_res
920
840
  )
921
- raise models.HTTPValidationError(data=response_data)
841
+ raise errors.HTTPValidationError(response_data, http_res)
922
842
  if utils.match_response(http_res, "4XX", "*"):
923
843
  http_res_text = await utils.stream_to_text_async(http_res)
924
- raise models.APIError(
925
- "API error occurred", http_res.status_code, http_res_text, http_res
926
- )
844
+ raise errors.APIError("API error occurred", http_res, http_res_text)
927
845
  if utils.match_response(http_res, "5XX", "*"):
928
846
  http_res_text = await utils.stream_to_text_async(http_res)
929
- raise models.APIError(
930
- "API error occurred", http_res.status_code, http_res_text, http_res
931
- )
847
+ raise errors.APIError("API error occurred", http_res, http_res_text)
932
848
 
933
- content_type = http_res.headers.get("Content-Type")
934
- http_res_text = await utils.stream_to_text_async(http_res)
935
- raise models.APIError(
936
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
937
- http_res.status_code,
938
- http_res_text,
939
- http_res,
940
- )
849
+ raise errors.APIError("Unexpected response received", http_res)
941
850
 
942
851
  def update(
943
852
  self,
@@ -1031,31 +940,20 @@ class Targets(BaseSDK):
1031
940
 
1032
941
  response_data: Any = None
1033
942
  if utils.match_response(http_res, "200", "application/json"):
1034
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
943
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
1035
944
  if utils.match_response(http_res, "422", "application/json"):
1036
- response_data = utils.unmarshal_json(
1037
- http_res.text, models.HTTPValidationErrorData
945
+ response_data = unmarshal_json_response(
946
+ errors.HTTPValidationErrorData, http_res
1038
947
  )
1039
- raise models.HTTPValidationError(data=response_data)
948
+ raise errors.HTTPValidationError(response_data, http_res)
1040
949
  if utils.match_response(http_res, "4XX", "*"):
1041
950
  http_res_text = utils.stream_to_text(http_res)
1042
- raise models.APIError(
1043
- "API error occurred", http_res.status_code, http_res_text, http_res
1044
- )
951
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1045
952
  if utils.match_response(http_res, "5XX", "*"):
1046
953
  http_res_text = utils.stream_to_text(http_res)
1047
- raise models.APIError(
1048
- "API error occurred", http_res.status_code, http_res_text, http_res
1049
- )
954
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1050
955
 
1051
- content_type = http_res.headers.get("Content-Type")
1052
- http_res_text = utils.stream_to_text(http_res)
1053
- raise models.APIError(
1054
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1055
- http_res.status_code,
1056
- http_res_text,
1057
- http_res,
1058
- )
956
+ raise errors.APIError("Unexpected response received", http_res)
1059
957
 
1060
958
  async def update_async(
1061
959
  self,
@@ -1149,28 +1047,17 @@ class Targets(BaseSDK):
1149
1047
 
1150
1048
  response_data: Any = None
1151
1049
  if utils.match_response(http_res, "200", "application/json"):
1152
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
1050
+ return unmarshal_json_response(models.ChannelTargetResponse, http_res)
1153
1051
  if utils.match_response(http_res, "422", "application/json"):
1154
- response_data = utils.unmarshal_json(
1155
- http_res.text, models.HTTPValidationErrorData
1052
+ response_data = unmarshal_json_response(
1053
+ errors.HTTPValidationErrorData, http_res
1156
1054
  )
1157
- raise models.HTTPValidationError(data=response_data)
1055
+ raise errors.HTTPValidationError(response_data, http_res)
1158
1056
  if utils.match_response(http_res, "4XX", "*"):
1159
1057
  http_res_text = await utils.stream_to_text_async(http_res)
1160
- raise models.APIError(
1161
- "API error occurred", http_res.status_code, http_res_text, http_res
1162
- )
1058
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1163
1059
  if utils.match_response(http_res, "5XX", "*"):
1164
1060
  http_res_text = await utils.stream_to_text_async(http_res)
1165
- raise models.APIError(
1166
- "API error occurred", http_res.status_code, http_res_text, http_res
1167
- )
1061
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1168
1062
 
1169
- content_type = http_res.headers.get("Content-Type")
1170
- http_res_text = await utils.stream_to_text_async(http_res)
1171
- raise models.APIError(
1172
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1173
- http_res.status_code,
1174
- http_res_text,
1175
- http_res,
1176
- )
1063
+ raise errors.APIError("Unexpected response received", http_res)