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/twilio.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  from .basesdk import BaseSDK
4
4
  from .sdkconfiguration import SDKConfiguration
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.numbers import Numbers
8
8
  from syllable_sdk.types import BaseModel, OptionalNullable, UNSET
@@ -96,31 +96,20 @@ class Twilio(BaseSDK):
96
96
 
97
97
  response_data: Any = None
98
98
  if utils.match_response(http_res, "200", "application/json"):
99
- return utils.unmarshal_json(http_res.text, models.Channel)
99
+ return utils.unmarshal_json_response(models.Channel, http_res)
100
100
  if utils.match_response(http_res, "422", "application/json"):
101
- response_data = utils.unmarshal_json(
102
- http_res.text, models.HTTPValidationErrorData
101
+ response_data = utils.unmarshal_json_response(
102
+ errors.HTTPValidationErrorData, http_res
103
103
  )
104
- raise models.HTTPValidationError(data=response_data)
104
+ raise errors.HTTPValidationError(response_data, http_res)
105
105
  if utils.match_response(http_res, "4XX", "*"):
106
106
  http_res_text = utils.stream_to_text(http_res)
107
- raise models.APIError(
108
- "API error occurred", http_res.status_code, http_res_text, http_res
109
- )
107
+ raise errors.APIError("API error occurred", http_res, http_res_text)
110
108
  if utils.match_response(http_res, "5XX", "*"):
111
109
  http_res_text = utils.stream_to_text(http_res)
112
- raise models.APIError(
113
- "API error occurred", http_res.status_code, http_res_text, http_res
114
- )
110
+ raise errors.APIError("API error occurred", http_res, http_res_text)
115
111
 
116
- content_type = http_res.headers.get("Content-Type")
117
- http_res_text = utils.stream_to_text(http_res)
118
- raise models.APIError(
119
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
120
- http_res.status_code,
121
- http_res_text,
122
- http_res,
123
- )
112
+ raise errors.APIError("Unexpected response received", http_res)
124
113
 
125
114
  async def get_by_id_async(
126
115
  self,
@@ -194,31 +183,20 @@ class Twilio(BaseSDK):
194
183
 
195
184
  response_data: Any = None
196
185
  if utils.match_response(http_res, "200", "application/json"):
197
- return utils.unmarshal_json(http_res.text, models.Channel)
186
+ return utils.unmarshal_json_response(models.Channel, http_res)
198
187
  if utils.match_response(http_res, "422", "application/json"):
199
- response_data = utils.unmarshal_json(
200
- http_res.text, models.HTTPValidationErrorData
188
+ response_data = utils.unmarshal_json_response(
189
+ errors.HTTPValidationErrorData, http_res
201
190
  )
202
- raise models.HTTPValidationError(data=response_data)
191
+ raise errors.HTTPValidationError(response_data, http_res)
203
192
  if utils.match_response(http_res, "4XX", "*"):
204
193
  http_res_text = await utils.stream_to_text_async(http_res)
205
- raise models.APIError(
206
- "API error occurred", http_res.status_code, http_res_text, http_res
207
- )
194
+ raise errors.APIError("API error occurred", http_res, http_res_text)
208
195
  if utils.match_response(http_res, "5XX", "*"):
209
196
  http_res_text = await utils.stream_to_text_async(http_res)
210
- raise models.APIError(
211
- "API error occurred", http_res.status_code, http_res_text, http_res
212
- )
197
+ raise errors.APIError("API error occurred", http_res, http_res_text)
213
198
 
214
- content_type = http_res.headers.get("Content-Type")
215
- http_res_text = await utils.stream_to_text_async(http_res)
216
- raise models.APIError(
217
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
218
- http_res.status_code,
219
- http_res_text,
220
- http_res,
221
- )
199
+ raise errors.APIError("Unexpected response received", http_res)
222
200
 
223
201
  def update(
224
202
  self,
@@ -298,31 +276,20 @@ class Twilio(BaseSDK):
298
276
 
299
277
  response_data: Any = None
300
278
  if utils.match_response(http_res, "200", "application/json"):
301
- return utils.unmarshal_json(http_res.text, models.Channel)
279
+ return utils.unmarshal_json_response(models.Channel, http_res)
302
280
  if utils.match_response(http_res, "422", "application/json"):
303
- response_data = utils.unmarshal_json(
304
- http_res.text, models.HTTPValidationErrorData
281
+ response_data = utils.unmarshal_json_response(
282
+ errors.HTTPValidationErrorData, http_res
305
283
  )
306
- raise models.HTTPValidationError(data=response_data)
284
+ raise errors.HTTPValidationError(response_data, http_res)
307
285
  if utils.match_response(http_res, "4XX", "*"):
308
286
  http_res_text = utils.stream_to_text(http_res)
309
- raise models.APIError(
310
- "API error occurred", http_res.status_code, http_res_text, http_res
311
- )
287
+ raise errors.APIError("API error occurred", http_res, http_res_text)
312
288
  if utils.match_response(http_res, "5XX", "*"):
313
289
  http_res_text = utils.stream_to_text(http_res)
314
- raise models.APIError(
315
- "API error occurred", http_res.status_code, http_res_text, http_res
316
- )
290
+ raise errors.APIError("API error occurred", http_res, http_res_text)
317
291
 
318
- content_type = http_res.headers.get("Content-Type")
319
- http_res_text = utils.stream_to_text(http_res)
320
- raise models.APIError(
321
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
322
- http_res.status_code,
323
- http_res_text,
324
- http_res,
325
- )
292
+ raise errors.APIError("Unexpected response received", http_res)
326
293
 
327
294
  async def update_async(
328
295
  self,
@@ -402,31 +369,20 @@ class Twilio(BaseSDK):
402
369
 
403
370
  response_data: Any = None
404
371
  if utils.match_response(http_res, "200", "application/json"):
405
- return utils.unmarshal_json(http_res.text, models.Channel)
372
+ return utils.unmarshal_json_response(models.Channel, http_res)
406
373
  if utils.match_response(http_res, "422", "application/json"):
407
- response_data = utils.unmarshal_json(
408
- http_res.text, models.HTTPValidationErrorData
374
+ response_data = utils.unmarshal_json_response(
375
+ errors.HTTPValidationErrorData, http_res
409
376
  )
410
- raise models.HTTPValidationError(data=response_data)
377
+ raise errors.HTTPValidationError(response_data, http_res)
411
378
  if utils.match_response(http_res, "4XX", "*"):
412
379
  http_res_text = await utils.stream_to_text_async(http_res)
413
- raise models.APIError(
414
- "API error occurred", http_res.status_code, http_res_text, http_res
415
- )
380
+ raise errors.APIError("API error occurred", http_res, http_res_text)
416
381
  if utils.match_response(http_res, "5XX", "*"):
417
382
  http_res_text = await utils.stream_to_text_async(http_res)
418
- raise models.APIError(
419
- "API error occurred", http_res.status_code, http_res_text, http_res
420
- )
383
+ raise errors.APIError("API error occurred", http_res, http_res_text)
421
384
 
422
- content_type = http_res.headers.get("Content-Type")
423
- http_res_text = await utils.stream_to_text_async(http_res)
424
- raise models.APIError(
425
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
426
- http_res.status_code,
427
- http_res_text,
428
- http_res,
429
- )
385
+ raise errors.APIError("Unexpected response received", http_res)
430
386
 
431
387
  def create(
432
388
  self,
@@ -506,31 +462,20 @@ class Twilio(BaseSDK):
506
462
 
507
463
  response_data: Any = None
508
464
  if utils.match_response(http_res, "200", "application/json"):
509
- return utils.unmarshal_json(http_res.text, models.Channel)
465
+ return utils.unmarshal_json_response(models.Channel, http_res)
510
466
  if utils.match_response(http_res, "422", "application/json"):
511
- response_data = utils.unmarshal_json(
512
- http_res.text, models.HTTPValidationErrorData
467
+ response_data = utils.unmarshal_json_response(
468
+ errors.HTTPValidationErrorData, http_res
513
469
  )
514
- raise models.HTTPValidationError(data=response_data)
470
+ raise errors.HTTPValidationError(response_data, http_res)
515
471
  if utils.match_response(http_res, "4XX", "*"):
516
472
  http_res_text = utils.stream_to_text(http_res)
517
- raise models.APIError(
518
- "API error occurred", http_res.status_code, http_res_text, http_res
519
- )
473
+ raise errors.APIError("API error occurred", http_res, http_res_text)
520
474
  if utils.match_response(http_res, "5XX", "*"):
521
475
  http_res_text = utils.stream_to_text(http_res)
522
- raise models.APIError(
523
- "API error occurred", http_res.status_code, http_res_text, http_res
524
- )
476
+ raise errors.APIError("API error occurred", http_res, http_res_text)
525
477
 
526
- content_type = http_res.headers.get("Content-Type")
527
- http_res_text = utils.stream_to_text(http_res)
528
- raise models.APIError(
529
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
530
- http_res.status_code,
531
- http_res_text,
532
- http_res,
533
- )
478
+ raise errors.APIError("Unexpected response received", http_res)
534
479
 
535
480
  async def create_async(
536
481
  self,
@@ -610,28 +555,17 @@ class Twilio(BaseSDK):
610
555
 
611
556
  response_data: Any = None
612
557
  if utils.match_response(http_res, "200", "application/json"):
613
- return utils.unmarshal_json(http_res.text, models.Channel)
558
+ return utils.unmarshal_json_response(models.Channel, http_res)
614
559
  if utils.match_response(http_res, "422", "application/json"):
615
- response_data = utils.unmarshal_json(
616
- http_res.text, models.HTTPValidationErrorData
560
+ response_data = utils.unmarshal_json_response(
561
+ errors.HTTPValidationErrorData, http_res
617
562
  )
618
- raise models.HTTPValidationError(data=response_data)
563
+ raise errors.HTTPValidationError(response_data, http_res)
619
564
  if utils.match_response(http_res, "4XX", "*"):
620
565
  http_res_text = await utils.stream_to_text_async(http_res)
621
- raise models.APIError(
622
- "API error occurred", http_res.status_code, http_res_text, http_res
623
- )
566
+ raise errors.APIError("API error occurred", http_res, http_res_text)
624
567
  if utils.match_response(http_res, "5XX", "*"):
625
568
  http_res_text = await utils.stream_to_text_async(http_res)
626
- raise models.APIError(
627
- "API error occurred", http_res.status_code, http_res_text, http_res
628
- )
569
+ raise errors.APIError("API error occurred", http_res, http_res_text)
629
570
 
630
- content_type = http_res.headers.get("Content-Type")
631
- http_res_text = await utils.stream_to_text_async(http_res)
632
- raise models.APIError(
633
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
634
- http_res.status_code,
635
- http_res_text,
636
- http_res,
637
- )
571
+ raise errors.APIError("Unexpected response received", http_res)