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/takeouts.py CHANGED
@@ -2,7 +2,7 @@
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
@@ -74,26 +74,15 @@ class Takeouts(BaseSDK):
74
74
  )
75
75
 
76
76
  if utils.match_response(http_res, "200", "application/json"):
77
- return utils.unmarshal_json(http_res.text, models.CreateTakeoutResponse)
77
+ return utils.unmarshal_json_response(models.CreateTakeoutResponse, http_res)
78
78
  if utils.match_response(http_res, "4XX", "*"):
79
79
  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
- )
80
+ raise errors.APIError("API error occurred", http_res, http_res_text)
83
81
  if utils.match_response(http_res, "5XX", "*"):
84
82
  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
- )
83
+ raise errors.APIError("API error occurred", http_res, http_res_text)
88
84
 
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
- )
85
+ raise errors.APIError("Unexpected response received", http_res)
97
86
 
98
87
  async def create_async(
99
88
  self,
@@ -159,26 +148,15 @@ class Takeouts(BaseSDK):
159
148
  )
160
149
 
161
150
  if utils.match_response(http_res, "200", "application/json"):
162
- return utils.unmarshal_json(http_res.text, models.CreateTakeoutResponse)
151
+ return utils.unmarshal_json_response(models.CreateTakeoutResponse, http_res)
163
152
  if utils.match_response(http_res, "4XX", "*"):
164
153
  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
- )
154
+ raise errors.APIError("API error occurred", http_res, http_res_text)
168
155
  if utils.match_response(http_res, "5XX", "*"):
169
156
  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
- )
157
+ raise errors.APIError("API error occurred", http_res, http_res_text)
173
158
 
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
- )
159
+ raise errors.APIError("Unexpected response received", http_res)
182
160
 
183
161
  def takeouts_get_by_job_id(
184
162
  self,
@@ -252,31 +230,20 @@ class Takeouts(BaseSDK):
252
230
 
253
231
  response_data: Any = None
254
232
  if utils.match_response(http_res, "200", "application/json"):
255
- return utils.unmarshal_json(http_res.text, models.TakeoutStatusResponse)
233
+ return utils.unmarshal_json_response(models.TakeoutStatusResponse, http_res)
256
234
  if utils.match_response(http_res, "422", "application/json"):
257
- response_data = utils.unmarshal_json(
258
- http_res.text, models.HTTPValidationErrorData
235
+ response_data = utils.unmarshal_json_response(
236
+ errors.HTTPValidationErrorData, http_res
259
237
  )
260
- raise models.HTTPValidationError(data=response_data)
238
+ raise errors.HTTPValidationError(response_data, http_res)
261
239
  if utils.match_response(http_res, "4XX", "*"):
262
240
  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
- )
241
+ raise errors.APIError("API error occurred", http_res, http_res_text)
266
242
  if utils.match_response(http_res, "5XX", "*"):
267
243
  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
- )
244
+ raise errors.APIError("API error occurred", http_res, http_res_text)
271
245
 
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
- )
246
+ raise errors.APIError("Unexpected response received", http_res)
280
247
 
281
248
  async def takeouts_get_by_job_id_async(
282
249
  self,
@@ -350,31 +317,20 @@ class Takeouts(BaseSDK):
350
317
 
351
318
  response_data: Any = None
352
319
  if utils.match_response(http_res, "200", "application/json"):
353
- return utils.unmarshal_json(http_res.text, models.TakeoutStatusResponse)
320
+ return utils.unmarshal_json_response(models.TakeoutStatusResponse, http_res)
354
321
  if utils.match_response(http_res, "422", "application/json"):
355
- response_data = utils.unmarshal_json(
356
- http_res.text, models.HTTPValidationErrorData
322
+ response_data = utils.unmarshal_json_response(
323
+ errors.HTTPValidationErrorData, http_res
357
324
  )
358
- raise models.HTTPValidationError(data=response_data)
325
+ raise errors.HTTPValidationError(response_data, http_res)
359
326
  if utils.match_response(http_res, "4XX", "*"):
360
327
  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
- )
328
+ raise errors.APIError("API error occurred", http_res, http_res_text)
364
329
  if utils.match_response(http_res, "5XX", "*"):
365
330
  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
- )
331
+ raise errors.APIError("API error occurred", http_res, http_res_text)
369
332
 
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
- )
333
+ raise errors.APIError("Unexpected response received", http_res)
378
334
 
379
335
  def takeouts_get_file(
380
336
  self,
@@ -455,29 +411,19 @@ class Takeouts(BaseSDK):
455
411
  return http_res
456
412
  if utils.match_response(http_res, "422", "application/json"):
457
413
  http_res_text = utils.stream_to_text(http_res)
458
- response_data = utils.unmarshal_json(
459
- http_res_text, models.HTTPValidationErrorData
414
+ response_data = utils.unmarshal_json_response(
415
+ errors.HTTPValidationErrorData, http_res, http_res_text
460
416
  )
461
- raise models.HTTPValidationError(data=response_data)
417
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
462
418
  if utils.match_response(http_res, "4XX", "*"):
463
419
  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
- )
420
+ raise errors.APIError("API error occurred", http_res, http_res_text)
467
421
  if utils.match_response(http_res, "5XX", "*"):
468
422
  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
- )
423
+ raise errors.APIError("API error occurred", http_res, http_res_text)
472
424
 
473
- content_type = http_res.headers.get("Content-Type")
474
425
  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
- )
426
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
481
427
 
482
428
  async def takeouts_get_file_async(
483
429
  self,
@@ -558,26 +504,16 @@ class Takeouts(BaseSDK):
558
504
  return http_res
559
505
  if utils.match_response(http_res, "422", "application/json"):
560
506
  http_res_text = await utils.stream_to_text_async(http_res)
561
- response_data = utils.unmarshal_json(
562
- http_res_text, models.HTTPValidationErrorData
507
+ response_data = utils.unmarshal_json_response(
508
+ errors.HTTPValidationErrorData, http_res, http_res_text
563
509
  )
564
- raise models.HTTPValidationError(data=response_data)
510
+ raise errors.HTTPValidationError(response_data, http_res, http_res_text)
565
511
  if utils.match_response(http_res, "4XX", "*"):
566
512
  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
- )
513
+ raise errors.APIError("API error occurred", http_res, http_res_text)
570
514
  if utils.match_response(http_res, "5XX", "*"):
571
515
  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
- )
516
+ raise errors.APIError("API error occurred", http_res, http_res_text)
575
517
 
576
- content_type = http_res.headers.get("Content-Type")
577
518
  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
- )
519
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
syllable_sdk/targets.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 OptionalNullable, UNSET
7
7
  from syllable_sdk.utils import get_security_from_env
@@ -109,33 +109,22 @@ class Targets(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(
113
- http_res.text, models.ListResponseAvailableTarget
112
+ return utils.unmarshal_json_response(
113
+ models.ListResponseAvailableTarget, http_res
114
114
  )
115
115
  if utils.match_response(http_res, "422", "application/json"):
116
- response_data = utils.unmarshal_json(
117
- http_res.text, models.HTTPValidationErrorData
116
+ response_data = utils.unmarshal_json_response(
117
+ errors.HTTPValidationErrorData, http_res
118
118
  )
119
- raise models.HTTPValidationError(data=response_data)
119
+ raise errors.HTTPValidationError(response_data, http_res)
120
120
  if utils.match_response(http_res, "4XX", "*"):
121
121
  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
- )
122
+ raise errors.APIError("API error occurred", http_res, http_res_text)
125
123
  if utils.match_response(http_res, "5XX", "*"):
126
124
  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
- )
125
+ raise errors.APIError("API error occurred", http_res, http_res_text)
130
126
 
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
- )
127
+ raise errors.APIError("Unexpected response received", http_res)
139
128
 
140
129
  async def available_targets_async(
141
130
  self,
@@ -235,33 +224,22 @@ class Targets(BaseSDK):
235
224
 
236
225
  response_data: Any = None
237
226
  if utils.match_response(http_res, "200", "application/json"):
238
- return utils.unmarshal_json(
239
- http_res.text, models.ListResponseAvailableTarget
227
+ return utils.unmarshal_json_response(
228
+ models.ListResponseAvailableTarget, http_res
240
229
  )
241
230
  if utils.match_response(http_res, "422", "application/json"):
242
- response_data = utils.unmarshal_json(
243
- http_res.text, models.HTTPValidationErrorData
231
+ response_data = utils.unmarshal_json_response(
232
+ errors.HTTPValidationErrorData, http_res
244
233
  )
245
- raise models.HTTPValidationError(data=response_data)
234
+ raise errors.HTTPValidationError(response_data, http_res)
246
235
  if utils.match_response(http_res, "4XX", "*"):
247
236
  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
- )
237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
251
238
  if utils.match_response(http_res, "5XX", "*"):
252
239
  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
- )
240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
256
241
 
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
- )
242
+ raise errors.APIError("Unexpected response received", http_res)
265
243
 
266
244
  def list(
267
245
  self,
@@ -359,33 +337,22 @@ class Targets(BaseSDK):
359
337
 
360
338
  response_data: Any = None
361
339
  if utils.match_response(http_res, "200", "application/json"):
362
- return utils.unmarshal_json(
363
- http_res.text, models.ListResponseChannelTargetResponse
340
+ return utils.unmarshal_json_response(
341
+ models.ListResponseChannelTargetResponse, http_res
364
342
  )
365
343
  if utils.match_response(http_res, "422", "application/json"):
366
- response_data = utils.unmarshal_json(
367
- http_res.text, models.HTTPValidationErrorData
344
+ response_data = utils.unmarshal_json_response(
345
+ errors.HTTPValidationErrorData, http_res
368
346
  )
369
- raise models.HTTPValidationError(data=response_data)
347
+ raise errors.HTTPValidationError(response_data, http_res)
370
348
  if utils.match_response(http_res, "4XX", "*"):
371
349
  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
- )
350
+ raise errors.APIError("API error occurred", http_res, http_res_text)
375
351
  if utils.match_response(http_res, "5XX", "*"):
376
352
  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
- )
353
+ raise errors.APIError("API error occurred", http_res, http_res_text)
380
354
 
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
- )
355
+ raise errors.APIError("Unexpected response received", http_res)
389
356
 
390
357
  async def list_async(
391
358
  self,
@@ -483,33 +450,22 @@ class Targets(BaseSDK):
483
450
 
484
451
  response_data: Any = None
485
452
  if utils.match_response(http_res, "200", "application/json"):
486
- return utils.unmarshal_json(
487
- http_res.text, models.ListResponseChannelTargetResponse
453
+ return utils.unmarshal_json_response(
454
+ models.ListResponseChannelTargetResponse, http_res
488
455
  )
489
456
  if utils.match_response(http_res, "422", "application/json"):
490
- response_data = utils.unmarshal_json(
491
- http_res.text, models.HTTPValidationErrorData
457
+ response_data = utils.unmarshal_json_response(
458
+ errors.HTTPValidationErrorData, http_res
492
459
  )
493
- raise models.HTTPValidationError(data=response_data)
460
+ raise errors.HTTPValidationError(response_data, http_res)
494
461
  if utils.match_response(http_res, "4XX", "*"):
495
462
  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
- )
463
+ raise errors.APIError("API error occurred", http_res, http_res_text)
499
464
  if utils.match_response(http_res, "5XX", "*"):
500
465
  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
- )
466
+ raise errors.APIError("API error occurred", http_res, http_res_text)
504
467
 
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
- )
468
+ raise errors.APIError("Unexpected response received", http_res)
513
469
 
514
470
  def create(
515
471
  self,
@@ -598,31 +554,20 @@ class Targets(BaseSDK):
598
554
 
599
555
  response_data: Any = None
600
556
  if utils.match_response(http_res, "200", "application/json"):
601
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
557
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
602
558
  if utils.match_response(http_res, "422", "application/json"):
603
- response_data = utils.unmarshal_json(
604
- http_res.text, models.HTTPValidationErrorData
559
+ response_data = utils.unmarshal_json_response(
560
+ errors.HTTPValidationErrorData, http_res
605
561
  )
606
- raise models.HTTPValidationError(data=response_data)
562
+ raise errors.HTTPValidationError(response_data, http_res)
607
563
  if utils.match_response(http_res, "4XX", "*"):
608
564
  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
- )
565
+ raise errors.APIError("API error occurred", http_res, http_res_text)
612
566
  if utils.match_response(http_res, "5XX", "*"):
613
567
  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
- )
568
+ raise errors.APIError("API error occurred", http_res, http_res_text)
617
569
 
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
- )
570
+ raise errors.APIError("Unexpected response received", http_res)
626
571
 
627
572
  async def create_async(
628
573
  self,
@@ -711,31 +656,20 @@ class Targets(BaseSDK):
711
656
 
712
657
  response_data: Any = None
713
658
  if utils.match_response(http_res, "200", "application/json"):
714
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
659
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
715
660
  if utils.match_response(http_res, "422", "application/json"):
716
- response_data = utils.unmarshal_json(
717
- http_res.text, models.HTTPValidationErrorData
661
+ response_data = utils.unmarshal_json_response(
662
+ errors.HTTPValidationErrorData, http_res
718
663
  )
719
- raise models.HTTPValidationError(data=response_data)
664
+ raise errors.HTTPValidationError(response_data, http_res)
720
665
  if utils.match_response(http_res, "4XX", "*"):
721
666
  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
- )
667
+ raise errors.APIError("API error occurred", http_res, http_res_text)
725
668
  if utils.match_response(http_res, "5XX", "*"):
726
669
  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
- )
670
+ raise errors.APIError("API error occurred", http_res, http_res_text)
730
671
 
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
- )
672
+ raise errors.APIError("Unexpected response received", http_res)
739
673
 
740
674
  def get_by_id(
741
675
  self,
@@ -812,31 +746,20 @@ class Targets(BaseSDK):
812
746
 
813
747
  response_data: Any = None
814
748
  if utils.match_response(http_res, "200", "application/json"):
815
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
749
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
816
750
  if utils.match_response(http_res, "422", "application/json"):
817
- response_data = utils.unmarshal_json(
818
- http_res.text, models.HTTPValidationErrorData
751
+ response_data = utils.unmarshal_json_response(
752
+ errors.HTTPValidationErrorData, http_res
819
753
  )
820
- raise models.HTTPValidationError(data=response_data)
754
+ raise errors.HTTPValidationError(response_data, http_res)
821
755
  if utils.match_response(http_res, "4XX", "*"):
822
756
  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
- )
757
+ raise errors.APIError("API error occurred", http_res, http_res_text)
826
758
  if utils.match_response(http_res, "5XX", "*"):
827
759
  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
- )
760
+ raise errors.APIError("API error occurred", http_res, http_res_text)
831
761
 
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
- )
762
+ raise errors.APIError("Unexpected response received", http_res)
840
763
 
841
764
  async def get_by_id_async(
842
765
  self,
@@ -913,31 +836,20 @@ class Targets(BaseSDK):
913
836
 
914
837
  response_data: Any = None
915
838
  if utils.match_response(http_res, "200", "application/json"):
916
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
839
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
917
840
  if utils.match_response(http_res, "422", "application/json"):
918
- response_data = utils.unmarshal_json(
919
- http_res.text, models.HTTPValidationErrorData
841
+ response_data = utils.unmarshal_json_response(
842
+ errors.HTTPValidationErrorData, http_res
920
843
  )
921
- raise models.HTTPValidationError(data=response_data)
844
+ raise errors.HTTPValidationError(response_data, http_res)
922
845
  if utils.match_response(http_res, "4XX", "*"):
923
846
  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
- )
847
+ raise errors.APIError("API error occurred", http_res, http_res_text)
927
848
  if utils.match_response(http_res, "5XX", "*"):
928
849
  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
- )
850
+ raise errors.APIError("API error occurred", http_res, http_res_text)
932
851
 
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
- )
852
+ raise errors.APIError("Unexpected response received", http_res)
941
853
 
942
854
  def update(
943
855
  self,
@@ -1031,31 +943,20 @@ class Targets(BaseSDK):
1031
943
 
1032
944
  response_data: Any = None
1033
945
  if utils.match_response(http_res, "200", "application/json"):
1034
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
946
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
1035
947
  if utils.match_response(http_res, "422", "application/json"):
1036
- response_data = utils.unmarshal_json(
1037
- http_res.text, models.HTTPValidationErrorData
948
+ response_data = utils.unmarshal_json_response(
949
+ errors.HTTPValidationErrorData, http_res
1038
950
  )
1039
- raise models.HTTPValidationError(data=response_data)
951
+ raise errors.HTTPValidationError(response_data, http_res)
1040
952
  if utils.match_response(http_res, "4XX", "*"):
1041
953
  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
- )
954
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1045
955
  if utils.match_response(http_res, "5XX", "*"):
1046
956
  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
- )
957
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1050
958
 
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
- )
959
+ raise errors.APIError("Unexpected response received", http_res)
1059
960
 
1060
961
  async def update_async(
1061
962
  self,
@@ -1149,28 +1050,17 @@ class Targets(BaseSDK):
1149
1050
 
1150
1051
  response_data: Any = None
1151
1052
  if utils.match_response(http_res, "200", "application/json"):
1152
- return utils.unmarshal_json(http_res.text, models.ChannelTargetResponse)
1053
+ return utils.unmarshal_json_response(models.ChannelTargetResponse, http_res)
1153
1054
  if utils.match_response(http_res, "422", "application/json"):
1154
- response_data = utils.unmarshal_json(
1155
- http_res.text, models.HTTPValidationErrorData
1055
+ response_data = utils.unmarshal_json_response(
1056
+ errors.HTTPValidationErrorData, http_res
1156
1057
  )
1157
- raise models.HTTPValidationError(data=response_data)
1058
+ raise errors.HTTPValidationError(response_data, http_res)
1158
1059
  if utils.match_response(http_res, "4XX", "*"):
1159
1060
  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
- )
1061
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1163
1062
  if utils.match_response(http_res, "5XX", "*"):
1164
1063
  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
- )
1064
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1168
1065
 
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
- )
1066
+ raise errors.APIError("Unexpected response received", http_res)