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/twilio.py CHANGED
@@ -2,11 +2,12 @@
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
9
9
  from syllable_sdk.utils import get_security_from_env
10
+ from syllable_sdk.utils.unmarshal_json_response import unmarshal_json_response
10
11
  from typing import Any, Mapping, Optional, Union, cast
11
12
 
12
13
 
@@ -96,31 +97,20 @@ class Twilio(BaseSDK):
96
97
 
97
98
  response_data: Any = None
98
99
  if utils.match_response(http_res, "200", "application/json"):
99
- return utils.unmarshal_json(http_res.text, models.Channel)
100
+ return unmarshal_json_response(models.Channel, http_res)
100
101
  if utils.match_response(http_res, "422", "application/json"):
101
- response_data = utils.unmarshal_json(
102
- http_res.text, models.HTTPValidationErrorData
102
+ response_data = unmarshal_json_response(
103
+ errors.HTTPValidationErrorData, http_res
103
104
  )
104
- raise models.HTTPValidationError(data=response_data)
105
+ raise errors.HTTPValidationError(response_data, http_res)
105
106
  if utils.match_response(http_res, "4XX", "*"):
106
107
  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
- )
108
+ raise errors.APIError("API error occurred", http_res, http_res_text)
110
109
  if utils.match_response(http_res, "5XX", "*"):
111
110
  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
- )
111
+ raise errors.APIError("API error occurred", http_res, http_res_text)
115
112
 
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
- )
113
+ raise errors.APIError("Unexpected response received", http_res)
124
114
 
125
115
  async def get_by_id_async(
126
116
  self,
@@ -194,31 +184,20 @@ class Twilio(BaseSDK):
194
184
 
195
185
  response_data: Any = None
196
186
  if utils.match_response(http_res, "200", "application/json"):
197
- return utils.unmarshal_json(http_res.text, models.Channel)
187
+ return unmarshal_json_response(models.Channel, http_res)
198
188
  if utils.match_response(http_res, "422", "application/json"):
199
- response_data = utils.unmarshal_json(
200
- http_res.text, models.HTTPValidationErrorData
189
+ response_data = unmarshal_json_response(
190
+ errors.HTTPValidationErrorData, http_res
201
191
  )
202
- raise models.HTTPValidationError(data=response_data)
192
+ raise errors.HTTPValidationError(response_data, http_res)
203
193
  if utils.match_response(http_res, "4XX", "*"):
204
194
  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
- )
195
+ raise errors.APIError("API error occurred", http_res, http_res_text)
208
196
  if utils.match_response(http_res, "5XX", "*"):
209
197
  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
- )
198
+ raise errors.APIError("API error occurred", http_res, http_res_text)
213
199
 
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
- )
200
+ raise errors.APIError("Unexpected response received", http_res)
222
201
 
223
202
  def update(
224
203
  self,
@@ -298,31 +277,20 @@ class Twilio(BaseSDK):
298
277
 
299
278
  response_data: Any = None
300
279
  if utils.match_response(http_res, "200", "application/json"):
301
- return utils.unmarshal_json(http_res.text, models.Channel)
280
+ return unmarshal_json_response(models.Channel, http_res)
302
281
  if utils.match_response(http_res, "422", "application/json"):
303
- response_data = utils.unmarshal_json(
304
- http_res.text, models.HTTPValidationErrorData
282
+ response_data = unmarshal_json_response(
283
+ errors.HTTPValidationErrorData, http_res
305
284
  )
306
- raise models.HTTPValidationError(data=response_data)
285
+ raise errors.HTTPValidationError(response_data, http_res)
307
286
  if utils.match_response(http_res, "4XX", "*"):
308
287
  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
- )
288
+ raise errors.APIError("API error occurred", http_res, http_res_text)
312
289
  if utils.match_response(http_res, "5XX", "*"):
313
290
  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
- )
291
+ raise errors.APIError("API error occurred", http_res, http_res_text)
317
292
 
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
- )
293
+ raise errors.APIError("Unexpected response received", http_res)
326
294
 
327
295
  async def update_async(
328
296
  self,
@@ -402,31 +370,20 @@ class Twilio(BaseSDK):
402
370
 
403
371
  response_data: Any = None
404
372
  if utils.match_response(http_res, "200", "application/json"):
405
- return utils.unmarshal_json(http_res.text, models.Channel)
373
+ return unmarshal_json_response(models.Channel, http_res)
406
374
  if utils.match_response(http_res, "422", "application/json"):
407
- response_data = utils.unmarshal_json(
408
- http_res.text, models.HTTPValidationErrorData
375
+ response_data = unmarshal_json_response(
376
+ errors.HTTPValidationErrorData, http_res
409
377
  )
410
- raise models.HTTPValidationError(data=response_data)
378
+ raise errors.HTTPValidationError(response_data, http_res)
411
379
  if utils.match_response(http_res, "4XX", "*"):
412
380
  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
- )
381
+ raise errors.APIError("API error occurred", http_res, http_res_text)
416
382
  if utils.match_response(http_res, "5XX", "*"):
417
383
  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
- )
384
+ raise errors.APIError("API error occurred", http_res, http_res_text)
421
385
 
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
- )
386
+ raise errors.APIError("Unexpected response received", http_res)
430
387
 
431
388
  def create(
432
389
  self,
@@ -506,31 +463,20 @@ class Twilio(BaseSDK):
506
463
 
507
464
  response_data: Any = None
508
465
  if utils.match_response(http_res, "200", "application/json"):
509
- return utils.unmarshal_json(http_res.text, models.Channel)
466
+ return unmarshal_json_response(models.Channel, http_res)
510
467
  if utils.match_response(http_res, "422", "application/json"):
511
- response_data = utils.unmarshal_json(
512
- http_res.text, models.HTTPValidationErrorData
468
+ response_data = unmarshal_json_response(
469
+ errors.HTTPValidationErrorData, http_res
513
470
  )
514
- raise models.HTTPValidationError(data=response_data)
471
+ raise errors.HTTPValidationError(response_data, http_res)
515
472
  if utils.match_response(http_res, "4XX", "*"):
516
473
  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
- )
474
+ raise errors.APIError("API error occurred", http_res, http_res_text)
520
475
  if utils.match_response(http_res, "5XX", "*"):
521
476
  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
- )
477
+ raise errors.APIError("API error occurred", http_res, http_res_text)
525
478
 
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
- )
479
+ raise errors.APIError("Unexpected response received", http_res)
534
480
 
535
481
  async def create_async(
536
482
  self,
@@ -610,28 +556,17 @@ class Twilio(BaseSDK):
610
556
 
611
557
  response_data: Any = None
612
558
  if utils.match_response(http_res, "200", "application/json"):
613
- return utils.unmarshal_json(http_res.text, models.Channel)
559
+ return unmarshal_json_response(models.Channel, http_res)
614
560
  if utils.match_response(http_res, "422", "application/json"):
615
- response_data = utils.unmarshal_json(
616
- http_res.text, models.HTTPValidationErrorData
561
+ response_data = unmarshal_json_response(
562
+ errors.HTTPValidationErrorData, http_res
617
563
  )
618
- raise models.HTTPValidationError(data=response_data)
564
+ raise errors.HTTPValidationError(response_data, http_res)
619
565
  if utils.match_response(http_res, "4XX", "*"):
620
566
  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
- )
567
+ raise errors.APIError("API error occurred", http_res, http_res_text)
624
568
  if utils.match_response(http_res, "5XX", "*"):
625
569
  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
- )
570
+ raise errors.APIError("API error occurred", http_res, http_res_text)
629
571
 
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
- )
572
+ raise errors.APIError("Unexpected response received", http_res)